Read Rules, following perlreftut

Here are a couple of simple rules for reading Perl /expressions/ involving reference. Let’s start with a simple expression, like $a->[2]

Read Rule 1: “EVERYTHING on arrow’s left is a reference.”

At runtime, Perl actually follows the operator precedence rules and evaluates that reference before it looks at the right side of the arrow. In other words, Perl completely ignores the right side when evaluting the left side.

If you follow Read Rule 1 and dereference/unwrap it, you usually get an array or hash (->{….). When you are confronted with a big expression, you should follow Read Rule 1 and spell things out. See examples later.

Armed with Read Rule 1, we are ready to spell out slightly complex expressions, where we need —

Read Rule 2: “Add the omitted arrows.” ie at places like ]{,,,,,, ][,,,,,, }[ … This is the reverse of one of the original Use Rules in some “perlreftutorial”. Read Rule 2 is simple, but helpful when you need a clear understanding.

$a->[87]{str1} # # # is equivalent to
$a->[87]->{str1} # # # Read Rule 2

$everything_on_the_left_of_last_arrow = $a->[87] ; # # # Read Rule 1
%hash3 = %{$everything_on_the_left_of_last_arrow}; # # # Use Rule 1

$everything_on_the_left_of_1st_arrow = $a; # # # Read Rule 1
@array3 = @{$a} ; # # # Use Rule 1
# now $array3 [87] == $a->[87] == $everything_on_the_left_of_last_arrow == a pointer to a hash
# now the 87th element of @array3 points to %hash3

Advertisements

timer && timerTask /duo/?

Before looking at ch11-ex1 java source codes, PONDER these issues:

wait() is the key method beneath the Timer system. Understand wait()
and u understand much of Timer.

A: container of the schedule() method

A: the runnable container of the run() method

Q: which class maintains the schedule and the job @@ see Timer api

Q: which thread executes the jobs in queue@@ timerTask, being a
runnable thread@@. See Timer api

Q: how do u list the jobs in queue@@

Q: basic functionalities embodied by timerTask@@
run() containing the actions to take.
the schedule, perhaps a specification of the next kickoff time.

Q: which class is runnable@@ Which class has a run() method@@

Q: which class has methods to SET the number of seconds for delay@@