Perl Monk, Perl Meditation | |
PerlMonks |
Re^2: not able to get last index of arrayby Lotus1 (Vicar) |
on Jun 04, 2016 at 15:36 UTC ( [id://1164917]=note: print w/replies, xml ) | Need Help?? |
Hi ww, When I run the OP's script with use warnings; added I don't see a warning for printing "@a" but I do get one for print $a[-2] since there is only one element in the OP's array. Here is the warning I get: Use of uninitialized value in print at C:\usr\pm\sort\1164677.pl line 7. When you print an array inside of double quotes it adds a space by default between the elements or whatever the Update: I forgot to mention also at the line (my @newstring) = sort {$a <=> $b} @numbers; you don't need the parentheses since defining an array is already in array context. These are nitpicky comments since your program works and answered the OPs questions, but it's my 2 cents worth. Update: Fixed the separator as pointed out by AnomalousMonk
In Section
Seekers of Perl Wisdom
|
|