in reply to Re^2: Questions on sort
in thread Questions on sort
In the code ($a =~ /(\d+)/)[0] <=> ($b =~ /(\d+)/)[0] the regular expression is used in a list slice with a single index which returns a scalar value which can be compared with the <=> operator. Without the list slice the regular expression would return TRUE or FALSE in scalar context.
In the code my($aa) = $a =~ /(\d+)/; the parentheses around $aa impose list context on the regular expression which in list context returns all the contents of capturing parentheses in the regular expression.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Questions on sort
by locked_user sundialsvc4 (Abbot) on Aug 16, 2011 at 12:23 UTC |