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:

$ catfiles.pl *.txt *.html > mynewfile.txt
And it looks like:
#!/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.

<-radiant.matrix->
A collection of thoughts and links from the minds of geeks
The Code that can be seen is not the true Code
"In any sufficiently large group of people, most are idiots" - Kaa's Law

Replies are listed 'Best First'.
Re^3: cat -ing Multiple files with Perl
by psychotic (Beadle) on Dec 07, 2005 at 16:05 UTC
    Actually, Windows does have a cat equivalent, even though less powerfull. It is called type. Usage:
    $type /? Displays the contents of a text file or files. TYPE [drive:][path]filename $
    And of course you can redirect and/or append to files by using '>>' or '>' respectivelly.
Re^3: cat -ing Multiple files with Perl
by Anonymous Monk on May 28, 2010 at 23:47 UTC
    too bad you never actually ran your code!