|
|
| Do you know where your variables are? | |
| PerlMonks |
Re: reverse functionby moritz (Cardinal) |
| on Jun 29, 2012 at 11:57 UTC ( #979108=note: print w/ replies, xml ) | Need Help?? |
|
As the documentation for reverse explains, using it in scalar context does string reversal, not list reversal. Thus it joins all arguments into a string and reverses it. If you want the other output, either leave off the scalar, or write
Note that this behavior confuses many newcomers (though usually they wonder why print reverse "abc"; doesn't reverse anything) and is inconsistent with how things are generally done elsewhere in Perl 5, so in Perl 6 reverse always reverses lists, and flip always reverses strings.
In Section
Seekers of Perl Wisdom
|
|
||||||||||||||||||||