Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re^2: sorting number

by AnomalousMonk (Archbishop)
on Apr 09, 2019 at 07:17 UTC ( [id://1232333]=note: print w/replies, xml ) Need Help??


in reply to Re: sorting number
in thread sorting number

[ $_, s/^CAORE//r =~ s/(\d+)/sprintf "%06d", $1/ger ] } @aa;

I don't understand the  s/^CAORE//r part of this expression. It seems to be doing nothing, and the sorted output is the same without it:

c:\@Work\Perl\monks>perl -wMstrict -le "my @aa = qw( CORE1 CORE12 CORE8 CORE233 COREA11 COREA12 COREA130 COREA115 ); my @sorted = map { $_->[0] } sort { $a->[1] cmp $b->[1] } map { [ $_, s/(\d+)/sprintf \"%06d\", $1/ger ] } @aa; print qq{@sorted}; " CORE1 CORE8 CORE12 CORE233 COREA11 COREA12 COREA115 COREA130
Can you please elaborate?


Give a man a fish:  <%-{-{-{-<

Replies are listed 'Best First'.
Re^3: sorting number
by Tux (Canon) on Apr 09, 2019 at 12:36 UTC
    1. It is a typo (CAORE instead of CORE) - answer edited
    2. Not required indeed

Enjoy, Have FUN! H.Merijn

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (5)
As of 2024-04-23 18:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found