http://qs321.pair.com?node_id=11124499


in reply to Re^2: 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?

Here's a capture in list context. Prettier?

#!/usr/bin/perl use strict; # https://perlmonks.org/?node_id=11124461 use warnings; my @list = ( '1,cat', '2,dog', '22,mouse', '11,eel', '001,elk', '13,mi +nk'); my @n; @n[ /(\d+),/ ] .= "$_\n" for @list; print grep defined, @n;

This is why perl is fun :)

Replies are listed 'Best First'.
Re^4: How can I sort my array numerically on part of the string? (updated)
by LanX (Saint) on Dec 02, 2020 at 11:06 UTC
    > This is why perl is fun :)

    and so memory efficient ...

    > Prettier?

    nope! :)

    Cheers Rolf
    (addicted to the Perl Programming Language :)
    Wikisyntax for the Monastery

      TY guys I learned a lot from your suggestions, and no one made me feel "dumb"... LOVE IT..

      Happy Holidays to all may Karma be your friend..