in reply to How can I sort my array numerically on part of the string?
maybe it has been mentioned before, but I can't seem to find it.
$a and $b are aliases of @list elements so $a=~s/,.+// will alter the original list.
That's why tybalt89 added an /r modifier in his solution
Actually I can't think of a useful application of aliasing in sort because elements are accessed multiple times in unpredictable ways.
any useful application???DB<93> $x=0; @list=a..d DB<94> x sort { $x++; ($a.=$x) cmp ($b.=$x) } @list 0 'a13' 1 'b14' 2 'c234' 3 'd2' DB<95> x @list 0 'a13' 1 'b14' 2 'c234' 3 'd2' DB<96>
Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery
|
|---|