Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine

Re: text sorting question

by plaid (Chaplain)
on Aug 03, 2000 at 00:37 UTC ( #25841=note: print w/replies, xml ) Need Help??

in reply to text sorting question, kinda

The first way that comes to mind offhand would be to do something like
my @top_lines; my @other_lines; while(<FILE>) { # whatever regex to strip out lines (/blahblah$/) ? push @top_lines, $_ : push @other_lines, $_; } print OUTFILE @top_lines; print OUTFILE @other_lines;
This would work well provided that the file doesn't get too big, as the entire thing is going to have to be kept in memory. But, if it's about 200k as you say, that should work fine.

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (9)
As of 2020-06-01 17:22 GMT
Find Nodes?
    Voting Booth?
    Do you really want to know if there is extraterrestrial life?

    Results (5 votes). Check out past polls.