Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

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 ( [id://11124499]=note: print w/replies, xml ) Need Help??


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..

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11124499]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (2)
As of 2024-03-19 06:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found