Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

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?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (3)
As of 2019-12-08 16:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?