RE: Please Help!!! Newbie Question

2005-09-01 Thread Bakken, Luke
Perl wrote:
> Hi List,
> 
> I have this script which actually returns the value of the filename
> with extension but If the file name is something like
> "c:\projects\text 009.txt" (having a space in filename which is
> common in windows). 
> This script only returns "text" instead of returning full name of
> file. Here is the script
> 
>   #!/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/suggestion will be appreicated.
> 
> Thanks a lot.



You asked this question yesterday and I provided adequate help. Why did
you not go with that? Here is the email:

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]
 




Re: Please Help!!! Newbie Question

2005-09-01 Thread Randy W. Sims

Perl wrote:

Hi List,

I have this script which actually returns the value of the filename with
extension but If the file name is something like "c:\projects\text 009.txt"
(having a space in filename which is common in windows).
This script only returns "text" instead of returning full name of file.


Hi Perl,

Are you quoting the filename on the command line? Most shells split 
arguments on whitespace. In your example $ARGV[0] contains 
"c:\projects\text", and $ARGV[1] contains "009.txt".


Randy.


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: Please Help!!! Newbie question

2005-08-31 Thread Eric Walker
On Wednesday 31 August 2005 09:12 am, 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.
print $path;

I think that will get it...
-- 
Eric Walker
EDA/CAD Engineer
Work: 208-368-2573

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




RE: Please Help!!! Newbie question

2005-08-31 Thread Bakken, Luke
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]