L
Len Philpot
I've read the FAQs (unless proven otherwise!) and examples, etc. but
don't know why this doesn't work...
#!perl # use your shebang of choice, this was on Windows
use warnings;
use strict;
use LWP::Simple;
# unwrap this line
my @cachepage = \
get('http://www.geocaching.com/seek/cache_details.aspx?wp=GC115K4');
# line in question (in @cachepage) looks like :
# <p><span id="ShortDescription">Should be quick and easy.</span></p>
foreach my $line (@cachepage)
{
if($line =~ /Should be quick/)
{
print("$line");
}
}
Instead of printing only the line that contains "Should be quick", it
prints every line. Breaking it down to a minimum, I tried :
#!perl
use warnings;
use strict;
my @a = qw(one two three four five fiver);
foreach my $line (@a)
{
if($line =~ /five/)
{
print("$line\n");
}
}
Which, of course, prints :
five
fiver
.... as expected. What's different except maybe the input data? Are the
tags throwing a wrench in things?
My apologies in advance if this is a FAQ or simple logical error. I'm
very much in learning mode with Perl these days.
Thanks!
don't know why this doesn't work...
#!perl # use your shebang of choice, this was on Windows
use warnings;
use strict;
use LWP::Simple;
# unwrap this line
my @cachepage = \
get('http://www.geocaching.com/seek/cache_details.aspx?wp=GC115K4');
# line in question (in @cachepage) looks like :
# <p><span id="ShortDescription">Should be quick and easy.</span></p>
foreach my $line (@cachepage)
{
if($line =~ /Should be quick/)
{
print("$line");
}
}
Instead of printing only the line that contains "Should be quick", it
prints every line. Breaking it down to a minimum, I tried :
#!perl
use warnings;
use strict;
my @a = qw(one two three four five fiver);
foreach my $line (@a)
{
if($line =~ /five/)
{
print("$line\n");
}
}
Which, of course, prints :
five
fiver
.... as expected. What's different except maybe the input data? Are the
tags throwing a wrench in things?
My apologies in advance if this is a FAQ or simple logical error. I'm
very much in learning mode with Perl these days.
Thanks!