Click here to get back home

Re: passing filename path with spaces to subs

 HomeNewsGroups | Search | About
 comp.lang.perl.misc    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
Re: passing filename path with spaces to subs Sandy 03-23-2008
Posted by Sandy on March 23, 2008, 11:22 pm
Please log in for more thread options
On Mar 23, 6:09 pm, news2...@wanadoo.es wrote:
> I have a basic question. It has to do with the way I pass files with
> spaces.

This has nothing to do with Perl. Just quote your argument so the
shell would not break it into two arguments:

--- t.pl ---
#!/usr/bin/perl -w
use strict;
my $first = $ARGV[0];
my $second = $ARGV[1] || '';

print "First: '$first'\n";
print "Second: '$second'\n";
---

no quotes
> ./t.pl blah blah
First: 'blah'
Second: 'blah'

quotes
> ./t.pl "blah blah"
First: 'blah blah'
Second: ''

/sandy
http://myperlquiz.com/

Posted by Ben Bullock on March 23, 2008, 11:37 pm
Please log in for more thread options
> On Mar 23, 6:09 pm, news2...@wanadoo.es wrote:
>
> > I have a basic question. It has to do with the way I pass files with
> > spaces.
>
> This has nothing to do with Perl.

Excuse me for saying so, Sandy, but I'm not sure whether you read the
original poster's question carefully. His problem is with the second
script, and it is a purely Perl problem.



Similar ThreadsPosted
Re: passing filename path with spaces to subs March 24, 2008, 2:18 am
globbing files with spaces in the path January 6, 2006, 4:57 pm
File-Find skips directories with spaces depending on path separator on Windows January 14, 2006, 8:20 pm
Exec/System call with spaces in exec path problem ... December 2, 2005, 1:41 pm
embedded perl path $ENV problem September 22, 2004, 4:29 pm
Subs: Returning two hashes January 8, 2005, 1:52 am
Carp & parameters passed to subs March 24, 2006, 4:41 am
REs Returning undef Not Being Passed to Subs April 6, 2006, 1:26 pm
B::Lint does not detect undefined subs August 7, 2006, 12:17 pm
lists,shift,subs and dumb question November 5, 2004, 5:23 pm

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap