in reply to Re: How to add hyperlink for every table data using perl?
in thread How to add hyperlink for every table data using perl?

foreach my $file (@files) { my ($dir, $root, $ext) = $file =~ m|(.*)/(.*)\.(.*)|; #print $dir; my $outfile = "$dir/$root.html"; #print "Found: $dir/$root", '.', $ext, ". Write: $outfile","\n"; + open my $fh_out, '>', $outfile or die "Can't open $outfile: $!","\ +n"; my $head = " <!doctype html> <html lang=\"en\"> <head> <meta charset=\"utf-8\"> <title>DCMS_CHECKLIST</title><tr><td>< +/td></tr> </head> <body> <table> <th>SL.NO</th><th>CHECKLIST ITEM</th><th>VALUE</th><th>COMMENTS</th><t +h>CONFIRMATION</th> <style> .bold { font-weight: bold; } .bold td { border: 0px; } table, th, td { border: 1px solid black; } </style>"; print $fh_out $head ; # write the header open my $fh, '<', $file or die "Can't open $file: $!"; while (my $line=<$fh>) { chomp $line; for($line) { s/(?:COMMENT|[&\\_@])//g; } my @data = split /:/, $line; my $class = $data[0] ? 'normal' : 'bold'; #print $fh_out qq[<tr class="$class"><td>] . join('</td><td>', spli +t(/:/,$line)) . "</td></tr>\n"; print $fh_out qq[<tr class="$class">]; # my %data; my $check=0; for my $word(@data){ $check++; print $fh_out '<td>'; if($check==1) { print $fh_out '<a href="'.$outfile{$word}.'">'; # print $fh_out '<a href="'.$word.' " >'; } print $fh_out $word; if($check==1) { print $fh_out '</a>'; } print $fh_out '</td>'; } print $fh_out "</tr>\n"; } }