Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine

Re: Opening multiple files

by kielstirling (Scribe)
on Jan 30, 2012 at 01:42 UTC ( #950681=note: print w/replies, xml ) Need Help??

in reply to Opening multiple files


If I understand correctly what you are wanting to do .. this is how I would do it.

Have fun !!

-Kiel R Stirling

#!/usr/bin/perl -w use strict; use IO::File; my $output = pop @ARGV; my @merge; for my $file (@ARGV) { my $input_fh = IO::File->new($file); die "failed to open $file\n" unless defined $input_fh; $merge[$.-1] .= $_ while (defined ($_ = <$input_fh>) and chomp); $input_fh->close; } my $output_fh = IO::File->new("> $output"); die "failed to open $output\n" unless defined $output_fh; $" = "\n"; print $output_fh "@merge"; $output_fh->close;

./ file1 file2 file3 output_file

Replies are listed 'Best First'.
Re^2: Opening multiple files
by mcasspj (Initiate) on Jan 30, 2012 at 16:45 UTC

    That's exactly what I wanted, just tweaked it and it's perfect!

    Many Thanks Paul

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://950681]
Discipulus ignores..
Discipulus IE just maps to id est in my mind .. ;=)
[Corion]: marto: I believe nowadays, at least window.opener should not be set anymore (except maybe within the same domain)
[Corion]: But I wouldn't really know as I don't use iexplore much (except at $work) and mostly surf with JS disabled (except at $work :) )

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (7)
As of 2018-03-21 11:43 GMT
Find Nodes?
    Voting Booth?
    When I think of a mole I think of:

    Results (267 votes). Check out past polls.