Another question on making no OS specific code

Another question on making no OS specific code

am 04.06.2007 17:12:09 von Ben Edwards

HI, fraid its me again,

I have the following code which I am trying to make non OS specific.

$ftp = Net::FTP->new( $remote_host ) or die "faild to connect to $remote_host";
$ftp->login( $remote_user, $remote_password ) or die "failed to login
$remote_user";
$ftp->cwd( $remote_dir ) or die "fail to cwd to $remote_dir";
$ftp->binary;

@files = $ftp->ls($flist) or die "failed to ls $flist";

foreach $file ( @files ) {
if ( $file !~ /No such file or directory/ ) {
print LOGFILE " Getting '$file' to $local_dir/$file\n";
$ftp->get( $file, "$local_dir/$file" ) or die "failed to get $file";
}
}

$ftp->quit;

The problem is:-

$file !~ /No such file or directory/

I am not entirely sure but this looks like a OS specific error (when
there is no files that match the pattern the error message becomes the
first item in the array). Anyone have a better solution to this?

Ben
--
Ben Edwards - Bristol, UK
If you have a problem emailing me use
http://www.gurtlush.org.uk/profiles.php?uid=4
(email address this email is sent from may be defunct)

--
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
http://learn.perl.org/

Re: Another question on making no OS specific code

am 04.06.2007 17:38:58 von Chas Owens

On 6/4/07, Ben Edwards wrote:
snip
> @files = $ftp->ls($flist) or die "failed to ls $flist";
>
> foreach $file ( @files ) {
> if ( $file !~ /No such file or directory/ ) {
snip
> I am not entirely sure but this looks like a OS specific error (when
> there is no files that match the pattern the error message becomes the
> first item in the array). Anyone have a better solution to this?
snip

On all of the platforms I tested (MS, FreeBSD, and Linux), a quick
test showed that the ls died rather than return "No such file or
directory" as the list of files. Are you seeing this in the wild? If
so, what platform and server?

--
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
http://learn.perl.org/