Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PAR: .exe and .pl do different things (WinXP) 1

Status
Not open for further replies.

vpk1

Technical User
Jul 20, 2011
1
AT
Hello!

I have a sript (see below) and
when I run the .pl and the .exe, the
results differ.
Some urls can be processed by both, other urls
only by the pl-script.

Can anyone tell me how to fix this?

Best regards,
Erich


Par:
> pp -o GetNews.exe GetNews.pl

Result .pl:
file://D:/tmp/perl/tst.xml: Data found!
Data found!
Data found!
Result .exe:

file://D:/tmp/perl/tst.xml: No Data!
No Data!
Data found!

Sript:
use LWP::Simple;

@urls = qw(
file://D:/tmp/perl/tst.xml
);

foreach $url (@urls){
$data = get( $url );
if (defined($data)){
print "$url: Data found!\n";
} else {
print "$url: No Data!\n";
}
}
 
I got the same result on Strawberry perl v5.12.1 where the exe failed with the first http url and successed when run as a script.

To debug the issue, it made sense to use a more verbose lwp module like LWP::UserAgent that actually contained error checking. Doing so fortunately and unfortunately just fixed the problem so I don't know why LWP::Simple had this pecularity:

Code:
require LWP::UserAgent;

use strict;
use warnings;

my @urls = qw(
	[URL unfurl="true"]http://kurier.at/newsfeed/wirtschaft_rss.xml[/URL]
	[URL unfurl="true"]http://kurier.at/newsfeed/oesterreich_rss.xml[/URL]
);

my $ua = LWP::UserAgent->new;

foreach my $url (@urls){
	my $response = $ua->get($url);

	if ($response->is_success) {
		print "$url: Data found!\n";
	} else {
		print "$url: No Data, " . $response->status_line . "\n";
	}
}

- Miller
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top