in reply to Re^2: Strange behaviour with Arrays and print?
in thread Strange behaviour with Arrays and print?
Because print takes a list as an argument so @fred is not coerced into scalar context. In your original print @fred."\n" the concatenation coerces scalar context, hence the "10" but if you'd used a comma instead of a full stop then that would have been a list and the elements of @fred would have been printed.
$ perl -Mstrict -Mwarnings -e ' > my @fred = qw{ one two three }; > print @fred . qq{\n}; > print @fred, qq{\n}; > print qq{@fred\n};' 3 onetwothree one two three
I hope this makes things clearer.
Cheers,
JohnGG
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Strange behaviour with Arrays and print?
by pingufreak83 (Initiate) on Jul 12, 2014 at 13:41 UTC |