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 (Parson)
on Apr 22, 2012 at 19:27 UTC ( #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.


Comment on Re: Schwartzian transform deformed with impunity
Download Code
Re^2: Schwartzian transform deformed with impunity
by jwkrahn (Monsignor) 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
Node Status?
node history
Node Type: note [id://966487]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (8)
As of 2014-09-01 14:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite cookbook is:










    Results (13 votes), past polls