[Israel.pm] Downloading using LWP
gaal at forum2.org
Wed Feb 18 02:49:25 PST 2009
What Avishalom and Mikhael said.
Note that it's worthwhile checking close as well: in some cases, e.g.
disk full errors, you might only get the error then.
While we're at it, consider the following two tips as well. They're
unlikely to be related to your current issue but may help you in the
1. Use lexical filehandles.
"FILE" is a global. You can "open my $fh, ..." instead, and $fh
becomes lexically scoped.
2. Use 3-arg open.
open my $fh, ">", $filename or die "open: $filename: $!";
is better than open my $fh, ">$filename". This is even more
significant in opens intended for reads. If your $filename
unexpectedly starts with a ">" or starts/ends with a "|", for example,
bad things can happen. The 3-arg form avoids those bad things.
On Wed, Feb 18, 2009 at 12:42 PM, Mikhael Goikhman <migo at homemail.com> wrote:
> On 18 Feb 2009 11:06:17 +0200, Berler Chanan wrote:
>> This is a small LWP utility I wrote:
>> It works fine using Windows, but it doesn't work when I try to download
>> a file into unix, does anyone knows what I did wrong?
> Does not work meaning what exactly? File not created or something else?
>> open FILE, ">$lv_plugin";
> Always check the system calls for failure:
> my $filename = "/tmp/" . $lv_plugin;
> open FILE, ">$filename" or die "Can't save $filename: $!\n";
> perl -e 'print+chr(64+hex)for+split//,d9b815c07f9b8d1e'
> Perl mailing list
> Perl at perl.org.il
Gaal Yahas <gaal at forum2.org>
More information about the Perl