readey has asked for the wisdom of the Perl Monks concerning the following question:
What surprised me was that the regular expression actually returns $1, which is in this case an integer digit. So the RE is returning a scalar variable which is in fact what it matched and not the number of times it matched. Is this perl magic, does it happen because the RE is wrapped inside [] or have I missed a fundamental point somewhere? Or (at the risk of getting a big head) have I discovered something?@sorted = map {$_->[0]} sort { $a->[1] <=> $b->[1] } map { [$_, /^file(\d+)\.csv$/]} @files;
update (broquaint): title change (was Is this magic?)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Is this magic?
by broquaint (Abbot) on Jan 07, 2003 at 16:27 UTC | |
|
(z) Re: Is this magic?
by zigdon (Deacon) on Jan 07, 2003 at 16:24 UTC | |
by bart (Canon) on Jan 07, 2003 at 18:31 UTC | |
|
Re: Is this magic?
by readey (Sexton) on Jan 07, 2003 at 16:47 UTC | |
|
Re: Is this magic?
by jdporter (Paladin) on Jan 07, 2003 at 17:51 UTC |