I want to highlight words. I provide the code and the errors generated by
the code.
Can somebody help me to fix the problem.

Thanks

Source.txt
Your AdWords text ads appear on search result pages for the keywords
you buy, and can be targeted by language and country. So, to reach
collectors of tin toys you might buy the keywords "toy collector,"
"tin toys," etc.

Phrases.txt (word to highlight)
AdWords text
Keywords
tin toys

Expected output (highlighted text)
Your (AdWords text) ads appear on search result pages for the
(keywords) you buy, and can be targeted by language and country. So,
to reach collectors of (tin toys) you might buy the keywords "toy
collector," "tin toys," etc.

The script
#!/usr/bin/perl
use strict;
use diagnostics;
use CGI qw/:standard/;
use CGI::Carp 'fatalsToBrowser';

my $regex;
{
    my $phrase_file = 'phrases.txt';
    open my $fh, $phrase_file or die "$phrase_file: $!";
        chomp( my @phrases = <$fh> );
        $_ = "(?:$_)" foreach @phrases;
        $regex = join '|', @phrases;
}

my $paragraph;
{
    my $source_file = 'source.txt';
    open my $fh, $source_file or die "$source_file: $!";
        chomp( my @source = <$fh> );
        $paragraph = join ' ', @source;
}

$paragraph =~ s/($regex)/b($1)/ige;
print p($paragraph);

__END__

Errors

<H1>Software error:</H1>
<CODE>Can't use an undefined value as a symbol reference at highlight2.pl
line 1
0.
</CODE>
<P>
For help, please send mail to this site's webmaster, giving this error
message
and the time and date of the error.

[Thu Nov 15 10:06:30 2001] highlight2.pl: Can't use an undefined value as a
symbol reference at


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to