Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: file merge problem

by injunjoel (Priest)
on Dec 09, 2005 at 22:41 UTC ( #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
Node Status?
node history
Node Type: note [id://515667]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (6)
As of 2019-07-16 16:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?