note
eyepopslikeamosquito
<P>
The difference is because the <a href="http://perldoc.perl.org/perlop.html#Range-Operators">range operator</a> behaves differently
in list context to scalar context.
BTW, so do arrays.
As indicated in the test program below, the array
returns the number of elements in scalar context,
while the flip flop operator returns false
(represented as undef), which prints as an empty string. Running:
<CODE>
use strict;
use warnings;
print "Counting up: " . (1..6) . "\n"; # scalar context (undef)
print "Counting up: " , (1..6) , "\n"; # list context
print "Counting up: @{[1..6]}\n"; # list context, space between each element
my @one_to_six = 1..6;
print "Counting up: " . @one_to_six . "\n"; # scalar context (no. of elts)
print "Counting up: " , @one_to_six , "\n"; # list context
</CODE>
produces:
<CODE>
Use of uninitialized value $. in range (or flip) at cnt.pl line 4.
Counting up:
Counting up: 123456
Counting up: 1 2 3 4 5 6
Counting up: 6
Counting up: 123456
</CODE>
</P>
1010116
1010116