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:
my @array = sort { $a <=> $b } $frstLength, $scndLength, $trdLength, $ +frthLength;
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,
| Athanasius <°(((>< contra mundum | Iustus alius egestas vitae, eros Piratica, |
In reply to Re: Length of strings in an array
by Athanasius
in thread Length of strings in an array
by shabird
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |