以下のファイルを出力リダイレクトなしで実行すると、出力は期待どおりになります。
出力
./get_urls.pl
www.site1.com
www.site2.com
www.siten.com
STDOUTをファイルにリダイレクトする場合、ファイルには何も記録されません。
./get_urls.pl > out
cat out
-
#!/usr/bin/perl
use LWP::Simple;
use strict;
use warnings;
my $i = 1;
while (my $contents = get("http://www.validpage.com?page=$i"))
{
#print STDERR $contents."\n".$url."\n";
#print STDERR $i."\n";
my @matches = ($contents =~ /_full'>(.*)?</g);
for my $match (@matches)
{
$match =~ s/\s//g;
print $match."\n";
}
$i++;
}
print STDERR "$i total matches.\n";
I suspect this behavior is a side effect of using LWP::Simple because output redirects as expected when the get() function call is omitted.