Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: Combining files

by rafl (Friar)
on Oct 23, 2006 at 03:13 UTC ( #579930=note: print w/ replies, xml ) Need Help??


in reply to Combining files

If you don't run on a *NIX platform or you don't have cat available for some other reason then something like this would do the job as well:

use IO::File; my $output_fh = IO::File->new( 'fullstaffinfo', 'w' ) or die $!; for my $input (<staffinfo*>) { my $input_fh = IO::File->new( $input, 'r' ) or die $!; $output_fh->print(do { local $/ = undef; <$input_fh> }); $input_fh->close; } $output_fh->close;

Cheers, Flo


Comment on Re: Combining files
Download Code
Replies are listed 'Best First'.
Re^2: Combining files
by ikegami (Pope) on Oct 23, 2006 at 04:44 UTC

    I don't think there's any guarantee of the order in which <staffinfo*> will return files. Adding sort avoids the problem. (I prefer to use glob explicitely over using the highly overloaded <...> notation.)

    for my input (sort glob 'staffinfo*') { ... }
Re^2: Combining files
by UrbanHick (Sexton) on Oct 23, 2006 at 07:23 UTC

    This looks like just the ticket.

    -Thanks!

    -UH

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (10)
As of 2015-07-28 15:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (257 votes), past polls