Thanks Luke... 

> 
> Programming Perl, 3rd ed page 1034 index: inplace edit, page 
> 495 and 665
>

        That helped, and I found a Merlyn post on perlmonks, see below,
which turned out to be a little too magical for me.  So the code below
is working, but parts of it still look strange to me, particularly the
part where I read the boilerplate from a file inside of the while<>.
Any suggestions for improvements would be welcome.  (Note, this is
Win32...) 


use warnings; 
use strict; 
use File::Find; 
use File::Slurp; 

#adapted from Randal Schwartz here:
http://www.perlmonks.com/index.pl?node_id=115428

{
  my @starters = @ARGV ? @ARGV : 'C:/test/';
  @ARGV = ();
  find sub {
  if ($_ ne ".") { #WHAT IS THIS "." FILE? SOME WINDOWS THING?   
  push @ARGV, "$File::Find::dir/$_";
  }
  }, @starters;
}

{
  local $/; # slurp it
  #local $^I; # = ".bak"; #NO BACKUP! YIKES! (gotta do 17,000 of 'em, no
room)

  while (<>) {
        my @path = split /\//, $ARGV;           
        my $boilerplate = read_file( 'bp.txt' ); #READ THIS FILE 17000
TIMES!?  
        $boilerplate =~ s/REPLACEME/$path[$#path]/g; #Replace string
"REPLACEME" with current filename.
        my $file = read_file( $ARGV ); 
        my $towrite = "$boilerplate$file"; 
        open (OUT, ">$ARGV"); #dangerous, but what the heck... 
        print OUT $towrite;        
  
  }
}

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to