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.
In reply to Re^3: Questions on sort
by jwkrahn
in thread Questions on sort
by jiashiun
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |