in reply to Re: cat -ing Multiple files with Perl
in thread cat -ing Multiple files with Perl
To expand on that, I do something which combines files specified by a glob into another. It is called like:
And it looks like:$ catfiles.pl *.txt *.html > mynewfile.txt
#!/usr/bin/perl use strict; use warnings; local $|=1; #turn of buffering for ( map { glob $_ } @ARGV ) { open my $FH, '<', $_ or do { warn "Can't open '$_' for read, skipping: $!"; next; } while (<$FH>) { print $_ } close $FH; }
Of course, on many systems cat *.txt *.html > mynewfile.txt works just fine, but this tool is useful because (a)I can extend it when I need to do more advanced work, and (b)Win32 doesn't have cat.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: cat -ing Multiple files with Perl
by psychotic (Beadle) on Dec 07, 2005 at 16:05 UTC | |
|
Re^3: cat -ing Multiple files with Perl
by Anonymous Monk on May 28, 2010 at 23:47 UTC |