Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: Schwartzian transform deformed with impunity

by dave_the_m (Prior)
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.

Replies are listed 'Best First'.
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?
[abner]: can someone give me a hint about how to query a mysql table based on matches in two columns?
[atcroft]: abner: Do you mean something like SELECT `foo`, `bar` FROM `table_name' WHERE (( `foo` = "asdf" ) OR ( `bar` = 'asdw' )); Or something else?
[abner]: yes. i am familiar with mysql but ignorant about how to get around the fact that placeholders can only represent single scalar values.

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (7)
As of 2017-01-24 03:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you watch meteor showers?




    Results (201 votes). Check out past polls.