A
ashishg
Hi,
I am currently reading Programming Perl.
Regarding the comma operator, on page 93, it says:
In a scalar context it evaluates its left argument, throws the value
away, then evaluates its right argument and returns that value.
On page 55, there is a code snippet:
while ($_ = ARGV[0], /^-/) {
shift;
last if /^--$/;
... # other lines
}
which is equivalent to:
while (<>) {
... # some code
}
I did not understand:
while ($_ = ARGV[0], /^-/) {
if ARGV[0] is to be evaluated and thrown away, and $_ is to be assigned
/^-/, then why not just say $_ = /^-/
I do not know the use/effect of $_ = /^-/ too ...
Thanks,
Ashish
I am currently reading Programming Perl.
Regarding the comma operator, on page 93, it says:
In a scalar context it evaluates its left argument, throws the value
away, then evaluates its right argument and returns that value.
On page 55, there is a code snippet:
while ($_ = ARGV[0], /^-/) {
shift;
last if /^--$/;
... # other lines
}
which is equivalent to:
while (<>) {
... # some code
}
I did not understand:
while ($_ = ARGV[0], /^-/) {
if ARGV[0] is to be evaluated and thrown away, and $_ is to be assigned
/^-/, then why not just say $_ = /^-/
I do not know the use/effect of $_ = /^-/ too ...
Thanks,
Ashish