Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

Re: Column Comparison of a File in Perl

by bv (Friar)
on Jan 19, 2010 at 21:43 UTC ( #818299=note: print w/replies, xml ) Need Help??

in reply to Column Comparison of a File in Perl

Your first problem is definitely the easiest. To loop over each line of the file, use while (<>) like so:

open my $outfile, '>', 'out.txt'; while (<>) { print $outfile $_ if /^(?:A id|M X)/; } close $outfile;

Obviously you may need a more rigorous regular expression, but this works for your example data. Your second problem is more difficult, so it'll have to wait for now.

Update: On second glance, your second probem is not well stated. What kind of comparison do you want to do? What should the output look like? Afraid I can't help with a poor problem statement.

print map{substr'hark, suPerJacent other l',$_,1}(11,7,6,16,5,1,15,18..23,8..10,24,17,0,12,13,3,14,2,4);

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (3)
As of 2020-02-21 13:44 GMT
Find Nodes?
    Voting Booth?
    What numbers are you going to focus on primarily in 2020?

    Results (96 votes). Check out past polls.