in reply to WARNING!! Possible Brainbench spoilers (do NOT read unless you've taken and passed the cert)
Is two statements in one. Look at it as:
my $data = ("Hello World" =~ /(.*) (.*)/);or more clearly. Assign the output of
"Hello World" =~ m/(.*) (.*)/);to
my $dataThe expression
"Hello World" =~ m/(.*) (.*)/;says to "run the match (m//) operator against the fixed string "Hello World". The output of the match operator is whether it matched: 1 (yes) 0 (no). Since Hello World matches 0 or more characters, a space, followed by 0 or more characters it returns 1 and the output of that is assigned to $data hence it has a value of 1.
From "man perlop"
"In scalar context, each execution of "m//g" finds the next match, returning true if it matches, and false if there is no further match.
That one is from the man pages too. "man perlmod"
A "BEGIN" subroutine is executed as soon as possible, that is, the moment it is completely defined, even before the rest of the containing file is parsed.
|
|---|