I am using Perl to achieve this
while(<INFILE>){
chomp;
if(/\<td/){
system("perl -i -e 's/<td/<td bgcolor="blue"/g' $_");
}
}
When I run the command I get
./HtmlTest.pl file.html
Bareword found where operator expected at ./HtmlTest.pl line 13, near ""perl -i -e 's/<td/<td bgcolor="grey"
(Missing operator before grey?)
String found where operator expected at ./HtmlTest.pl line 13, near "grey"/g' $_""
syntax error at ./HtmlTest.pl line 13, near ""perl -i -e 's/<td/<td bgcolor="grey"
Execution of ./HtmlTest.pl aborted due to compilation errors.
I am not able to figure out why
Even if i run as
perl HtmlTest.pl file.html
I get the same errors.
Sample html table
<td>ABC</td>
<td>DEF</td>
<td>20:00:00</td>
Any advice appreciated
perl -i -pe ...(assuming you meant-p) expects a filename argument but you are giving it$_which is the current line in the HTML file. It is not going to work. Try this instead:perl -pie 's/<td/<td bgcolor="blue"/' file.htmlTie::Fileyou can edit a file as you are reading it. But don't do that in this case. Using Håkon's solution seems much better.