in reply to Re: How can I sort my array numerically on part of the string? (updated)
in thread How can I sort my array numerically on part of the string?
You need that (...)[0] for the match to return the captures in list context, ( <=> is enforcing scalar context and m// only returns captures in list context otherwise boolean )
I'm wondering if there is a prettier solution for that.
The Schwartzian transform doesn't have that limitation.
... map { [$_, /(\d+),/] } @list;
should do already.
clarification: any better solution than (...)[0] to get list context ?
Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: How can I sort my array numerically on part of the string? (updated)
by tybalt89 (Monsignor) on Dec 02, 2020 at 03:17 UTC | |
by LanX (Saint) on Dec 02, 2020 at 11:06 UTC | |
by misterperl (Friar) on Dec 02, 2020 at 13:44 UTC | |
|
Re^3: How can I sort my array numerically on part of the string? (updated)
by misterperl (Friar) on Dec 02, 2020 at 13:24 UTC | |
by LanX (Saint) on Dec 02, 2020 at 13:41 UTC | |
by Anonymous Monk on Dec 02, 2020 at 13:26 UTC |