concating files together

Marty Pauley marty+belfast-pm at kasei.com
Fri May 23 11:40:07 CDT 2003


On Fri May 23 14:46:27 2003, Boyle Bernadette wrote:
>  
> Can anyone tell me id there is a Perl command to concat files into one. 
>  
> more /var/log/maillog* > /tmp/output

I would do something like:

  open my $out, ">", "/tmp/output" or die $!;
  for my $f (glob("/var/log/maillog*")) {
    open my $in, "<", $f or next;
    print {$out} <$in>;
    close $in;
  }
  close $out;

-- 
Marty
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 212 bytes
Desc: not available
Url : http://mail.pm.org/archives/belfast-pm/attachments/20030523/ced90e11/attachment.bin


More information about the Belfast-pm mailing list