At the moment I can't think of why this makes a difference (somebody
help me here), but you aren't specifying a mode for the open() function.
Also, you're not checking whether your match succeeded before using $1
(which is what I think you meant on that last line).

I personally would write it a little more like this for clarity:

####################

#!/usr/bin/perl
use warnings;
use strict;

open(LYNX,"<","lynx -source http://www.perl.com/ |") or die("Can't open
lynx: $!");

until($_ =~ /standard\.def/){
   $_ = <LYNX>;
}
my $head = <LYNX>;

if($head =~ m|^<A HERF=[^>]+>(.*?)</a>|i){
   print "Today's www.perl.com headline: $1\n";
}else{
   print "ERROR: Unable to get today's perl.com headline: $!\n";
}

####################

I can't test the rest of it, though, because I don't actually have lynx
on my system.





-----Original Message-----
From: Ryan Dillinger [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, July 11, 2006 6:28 PM
To: beginners@perl.org
Subject: pattern match

<snip>

Use of uninitialized value in pattern match (m//) at headline.pl line 7
and 10. 

<snip>

#!/usr/bin/perl
use warnings;
use strict;

open LYNX, "lynx -source http://www.perl.com/ |" or die "Can't open
lynx: 
$!";
$_ = "";
$_ = <LYNX> until /standard\.def/;

my $head = <LYNX>;
$head =~ m|^<A HERF=[^>]+>(.*?)</a>|i;

print "Today's www.perl.com headline: $!\n";



--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to