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

Re: Schwartzian transform deformed with impunity

by dave_the_m (Monsignor)
on Apr 22, 2012 at 19:27 UTC ( [id://966487]=note: print w/replies, xml ) Need Help??


in reply to Schwartzian transform deformed with impunity

If the file format really is as fixed as you describe, with only the number component varying, then you could strip off everything except the number, sort the numbers, then print out or assign to an array while reconstructing the file name from the number:
use strict; use warnings; print map "sequence$_.gb.txt\n", sort { $a <=> $b } map { /(\d+)/; $1 } <DATA>; __DATA__ sequence3.gb.txt ....

Dave.

Replies are listed 'Best First'.
Re^2: Schwartzian transform deformed with impunity
by jwkrahn (Abbot) on Apr 23, 2012 at 11:18 UTC
    map { /(\d+)/; $1 }

    No, that is wrong.    If /(\d+)/ doesn't match then $1 will not contain valid data:

    $ perl -le' use Data::Dumper; my @y = map { /(\d+)/; $1 } qw/ ab123cd ab456cd abcdefg ab789cd /; print Dumper \@y; ' $VAR1 = [ '123', '456', undef, '789' ];

    Just use:

    $ perl -le' use Data::Dumper; my @y = map /(\d+)/, qw/ ab123cd ab456cd abcdefg ab789cd /; print Dumper \@y; ' $VAR1 = [ '123', '456', '789' ];

    The regular expression by itself will just do the right thing.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (None)
    As of 2024-04-25 03:54 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      No recent polls found