in reply to How to process multiple input files?
So, I'm guessing that you didn't try it this way:
That works for me. (BTW, I'm compulsive about making the indentation look right -- seems silly, but it's really helpful to keep code less illegible.)#!/usr/bin/perl use strict; use warnings; for my $f ( @ARGV ) { local $/; open( I, '<', $f ); open( O, '>', "$f.bak" ); my $count = 0; my $line = <I>; $line =~ s{ (<\/div>) } { if (++$count == 2){ "\t<?php include(\$_SERVER['DOCUMENT_ROOT'].\"\/incl +udes\/footer.php\"); ?>\n\n".$1; } else { $1; } }gex; print O $line; }
If you have so many files that you can't fit them all as args on a command line, there's the unix "xargs" tool:
ls | xargs your_prog ## or use "find ... | xargs your_prog"
|
|---|