in reply to how do i parse multiple files and write all of the results into single file

my @files = glob( '2005*@*.log' ); die "No files found\n" unless @files; open(OUTPUT, ">output" ) or die "Unable to open output\n$!\n"; foreach my $file (@files) { open( MYFILE, $file ) or die "Unable to open $file\n$!\n"; while (<MYFILE>) { # parse print OUTPUT $parsed_output; } close (MYFILE) or die "Unable to properly close $file\n$!\n"; } close(OUTPUT);
  • Comment on Re: how do i parse multiple files and write all of the results into single file
  • Download Code

Replies are listed 'Best First'.
Re^2: how do i parse multiple files and write all of the results into single file
by QM (Parson) on Jul 08, 2005 at 18:22 UTC
    Transient did a great job giving a generally safe and applicable answer, though a bit wordy for my tastes. Pass the filename wildcard on the command line, and redirect STDOUT:
    #@ARGV = glob( @ARGV ); # needed for DOS while (<>) { s/match this/replace it with this/; print; }

    -QM
    --
    Quantum Mechanics: The dreams stuff is made of

Re^2: how do i parse multiple files and write all of the results into single file
by my_perl (Initiate) on Jul 08, 2005 at 18:10 UTC
    THank you very much :)