The problem is your slurp of all the lines in your join, I think. -i only works right if it can match up your print to the file currently being read, and your <> slurped up all the files.
I _think_ this may work better for you (untested!):
It's alway safer to use .bak on your -i, in case of disasters like the one you mentioned in your post.perl -i.bak -ne'if($f ne $ARGV[0]){if(defined($f)){print "prepend\n",@ +lines,"append\n"; @lines=();} $f=$ARGV[0]} push @lines,$_;' *.html */ +*.html */*/*.html */*/*/*.html
If it all worked, it's easy to get rid of the .bak files.
You might also want to think about using find | xargs instead of the nested directory wildcards; it's probably going to work more efficiently, and it won't croak on a huge directory tree.
--
Mike
In reply to Re: In-place header/footer
by RMGir
in thread In-place header/footer
by swiftone
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |