in reply to Strange behaviour with Arrays and print?
Perl sees your last line as
print( (@fred."\n") );
... that is, it first evaluates @fred . "\n" and then prints that result.
. evaluates its operands in scalar context. An array in scalar context evaluates to the number of its elements. Your expression then becomes
print( (scalar(@fred),"\n") );
... which is
print 10,"\n";
If you want to print an array, maybe put it in string context first:
print "@fred\n";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Strange behaviour with Arrays and print?
by CountZero (Bishop) on Jul 12, 2014 at 13:04 UTC | |
|
Re^2: Strange behaviour with Arrays and print?
by pingufreak83 (Initiate) on Jul 12, 2014 at 13:20 UTC | |
by johngg (Canon) on Jul 12, 2014 at 13:36 UTC | |
by pingufreak83 (Initiate) on Jul 12, 2014 at 13:41 UTC | |
by AnomalousMonk (Archbishop) on Jul 12, 2014 at 13:30 UTC |