Re: Need help with a Perl Script Error
From: Joe Smith (Joe.Smith_at_inwap.com)
Date: 04/04/04
- Next message: Joe Smith: "Re: Sad experience with redirecting to /dev/null"
- Previous message: Joe Smith: "Re: free source for bbs"
- In reply to: Darren Clark: "Need help with a Perl Script Error"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sun, 04 Apr 2004 09:36:29 GMT
Darren Clark wrote:
> #Strip directory structure
> $name=~m/^.*(\\|\/)(.*)/; # strip the remote path and keep the filename
> my $newname = $2;
You are blindly using $2 without bothering to check if m// succeeded. That
is guarenteed to fail for $name="My G5:Main directory:Subdir:File Name".
At bare minimum, change that to
my $newname = $name =~ s/.*[/:\\]//;
or "use File::Spec;" to split off the directory part.
-Joe
- Next message: Joe Smith: "Re: Sad experience with redirecting to /dev/null"
- Previous message: Joe Smith: "Re: free source for bbs"
- In reply to: Darren Clark: "Need help with a Perl Script Error"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]