rnaeye has asked for the wisdom of the Perl Monks concerning the following question:
Hi!
Script below inserts a line above SECOND
Thank you.
My script:
#!/usr/bin/perl use strict; use warnings; $^I = ".bak"; undef $/; my $count = 0; my $line = <>; $line =~ s { (<\/div>) } { if (++$count == 2){ "\t<?php include(\$_SERVER['DOCUMENT_ROOT' +].\"\/includes\/footer.php\"); ?>\n\n".$1; } else { $1; } }gex; print $line;
Sample input file:
<html lang="en"> <body> <!-- a lot of text here --> <div id="masthead" > <!-- a lot of text here --> </div> <!-- ############################################### --> <div id="wrapper" > <!--a lot of text here--> </div> </body> </html>