Ah. So the output you show is not the output your script actually generates.
I would split up the task into two steps:
- Check whether a hyperlink should be added to a line
- Print the line with a hyperlink or print it without
For the first step, you should write a subroutine needsHyperlink, which checks whether a line needs a hyperlink:
sub needsHyperlink {
my( $line ) = @_;
... # see perldoc perlre for checking
}
Then, you call that function to see whether you need to add a hyperlink in the output or not:
my $outputHyperlink = needsHyperlink( $line );
if( $outputHyperlink ) {
# print line with hyperlink
} else {
# print line without hyperlink, or maybe don't print it at all
};
Update: added second sentence about not printing things |