Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: file merge problem

by injunjoel (Priest)
on Dec 09, 2005 at 22:41 UTC ( [id://515667]=note: print w/replies, xml ) Need Help??


in reply to file merge problem

Greetings,
Just a thought.
#!/usr/bin/perl -w use strict; my %d = map{ /^(\w+) /; $1, $_; }grep{ chomp; /^\w+ \d+/; }map{ local @ARGV = ($_); <>; }<F*.dat>; open(MRG, ">merge.dat") or die "Oops! There was a problem: $!"; print MRG, $d{$_}."\n" for(sort keys %d); close MRG;
This assumes your input filenames match the pattern "F*.dat" for the glob to work on.

Updates

Thanks jdporter for the lower map suggestion. Much cleaner. Way better than the if(open (IN, $_)){#stuff} I was using.


BTW: we are Monks not Mongers :}

-InjunJoel
"I do not feel obliged to believe that the same God who endowed us with sense, reason and intellect has intended us to forego their use." -Galileo

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (4)
As of 2024-04-19 23:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found