Hello David. On Tue, 07 May 2013 20:26:23 -0700 David Christensen <dpchr...@holgerdanske.com> wrote:
> 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 This is better: http://perl-begin.org/tutorials/bad-elements/#properly_autoflushing > print `cat * >>foo.out`; # [2] qx// This is the same as «system('cat * >> foo.out')» (only more costly), and the command in this case should not emit any output (because it is redirected to a file). Furthermore, many non-UNIX-like systems don't contain a cat command. See: http://perl-begin.org/tutorials/bad-elements/ Regards, Shlomi Fish -- ----------------------------------------------------------------- Shlomi Fish http://www.shlomifish.org/ Optimising Code for Speed - http://shlom.in/optimise The X in XSLT stands for eXtermination. — http://www.shlomifish.org/humour/bits/facts/XSLT/ Please reply to list if it's a mailing list post - http://shlom.in/reply . -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/