Why not try grabbing all the important stuff right out of the pattern, 
like my example below.  Note:  Your pattern may need changes if I 
assumed too much, from your examples.

#!/usr/bin/perl
while (<>) {
if (m!<font class="fontclassz"><a href="([^"]+)">([^<]+)</a></font>!) {
print qq(<a href="$1" target="_blank" value="$2">);
}
}

On Tuesday, September 17, 2002, at 10:05  AM, Ian wrote:

> Hi,
>
> Please excuse this newbie question, but I am getting confused :(
>
> I need at have a small script that will extract selected words from a
> phrase
> and then insert them into a new string. I have an html page that I need
> to
> extract both urls & keywords from and put them into a new file. Should
> be
> fairly simple stuff - but it is beating me!!
>
> A typical example is
> <font class="fontclassz"><a href="http://domain.name";>text</a></font>
>
> The output needs to be as
> <a href="http://domain.name"; target="_blank" value="text">
>
> The first part and the last bit appear to be working (just), but it is
> the
> middle that I am stuck on.
>
> What I have put together so far is....
>
> #!/usr/bin/perl
> while ($line=<>) {
> if ($line =~ m|<font class="fontclassz">(.*?)</font>|) {
> $headline = $line;
> $url = $line;
> $line = $1;
> $headline =~ s|<[^>]*>||g;
> $url =~ s|<[^>]*>||g;
> $line = <<END;
> <a href="$url" target="_blank" value="$headline">
> END
> print "$line\n";
> }
> }
>
> I realise that both $headline and $url are the same at the moment, but
> having tried various alternatives, I am just getting more and more
> confused.
> Any assistance would be gratefully received.
>
> Ian
>
>
>
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>


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

Reply via email to