"be consistent" | |
PerlMonks |
Re: Length of strings in an arrayby Athanasius (Archbishop) |
on Sep 20, 2020 at 16:27 UTC ( [id://11121964]=note: print w/replies, xml ) | Need Help?? |
Hello shabird, it gives the length of the string but it also counts the enter key You should chomp the string to remove the trailing newline before finding the length. the order is not sorted although i have used to sort function for that. By default, sort sorts in lexicographical order, so 100 comes before 90 because 1 comes before 9. To sort numerically, do this:
You should also begin your script with use strict;, which forces you to declare each variable with my. (This is a good thing! It will save you a lot of debugging time in the long run.) Hope that helps,
In Section
Seekers of Perl Wisdom
|
|