Perl wrote:
> I am new to perl so I need some help from the list with this script.
> It takes a value from command line and then returns afters processing.
> For example, If value is "c:\projects\test 2005.txt" the script will
> returns it as "test" (actually omitts any space in the directory or
> file name) while I want the full name of the file regardless of any
> space in the directory or filename.
> how can I get the value "test 2005.txt"?
> 
>   #!/usr/bin/perl
>   # file: basename.pl
>   use strict;
>   use File::Basename;
>   my $path = $ARGV[0];
>   my $base = basename($path);
>   my $dir  = dirname($path);
>   print STDOUT $base;
> 
> 
> any help will be greatly appreciated.
> 
> Thanks in advance.


It works for me:

C:\>perl -MFile::Basename -e"print basename q(c:\projects\test
2005.txt)"
test 2005.txt

How are you executing the script? Are you surrounding c:\projects\test
2005.txt with quotes when you call the script? If not, $ARGV[0] will
only contain "c:\projects\test".

Why not put a "print join ':', @ARGV" in your script and you'll see what
I mean.

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to