Jair Santos wrote:
> Hi all,
>
> say that
use strict; # always
use warnings; # usually
> $directory = "C:\\directory\\*.*"
Use single quotes for cuter code.
my $directory = 'C:\directory\*.*';
> and I am trying to remove the *.* from the end using
>
> $directory = trim($directory);
>
>
> where
>
> trim is
>
> sub trim {
> my( $result) = @_;
>
> $result =~ s/^\s+(.*?)\s+$/$1/;
> $result =~ s/\s//g;
> return $result;
> }
>
>
> Can anybody point me out why it is not working?
Your 'trim' subroutine removes leading and trailing
whitespace from the string - it has nothing to do
with taking the path from a filename.
Try this:
use strict;
use File::Basename;
my $directory = 'C:\directory\*.*';
$directory = dirname $directory;
print $directory, "\n";
OUTPUT
C:\directory
HTH,
Rob
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]