On 05/07/13 11:00, Sherman Willden wrote:
... I downloaded the
Oreilly Programming Perl Version 4 examples. There are 30 directories
with 2211 files.  I want each chapter to have a consolidated file with
all the examples for that chapter. I created the
consolidate_examples.pl script which goes into each directory, reads
each file, and then writes the files lines to the
consolidated_perl4_examples/<directory name>. ...

1. I hope you don't expect the "consolidated file" to be a valid Perl program (?)...

2. Rather than reading/ writing the files programmatically with Perl, why not use Perl to invoke "cat" via the backticks operator (e.g. shell script):

        $| = 1;                         # [1] $OUTPUT_AUTOFLUSH
        print `cat * >>foo.out`;  # [2] qx//
        if ($? != 0) {                  # [3] $CHILD_ERROR
            # error handling --         
        }

HTH,

David



References:

[1] http://perldoc.perl.org/perlvar.html#Variables-related-to-filehandles

[2] http://perldoc.perl.org/perlop.html#Quote-Like-Operators

[3] http://perldoc.perl.org/perlvar.html#Error-Variables


--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to