Click here to get back home

Trouble with @ARGV

 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
Trouble with @ARGV ff0000 04-09-2008
Posted by ff0000 on April 9, 2008, 5:17 am
Please log in for more thread options
Hi,

I'm in trouble and doubt (is it a Perl or shell (Bash) fault? :-)
while understanding the
@ARGV behaviour... Here's a simple (newbie) script:

--
#!/usr/bin/perl

print "ARGV: `" . "@ARGV" . "`\n";

for my $i (0..$#ARGV) {
print "Argument[$]: `" . $ARGV[$i] . "`\n";

}

1;
--

First case:

ff0000@tsi00588pc:tmp$ ./test.pl "a b c"
ARGV: `a b c`
Argument[0]: `a b c`

The "a b c" quoting has been eating up; ok let's protect it:

ff0000@tsi00588pc:tmp$ ./test.pl \"a b c\"
ARGV: `"a b c"`
Argument[0]: `"a`
Argument[1]: `b`
Argument[2]: `c"`

Ouch! The protection has splitted the string... :-/...
Is there a way (without using extra modules) to preserve quoting
through
@ARGV?

Thanks a lot.
ff0000

Similar ThreadsPosted
How do I use " and \n in @ARGV[1]? October 19, 2004, 9:56 am
Probs with @ARGV July 21, 2004, 6:50 pm
@ARGV not working October 25, 2004, 1:52 pm
The array ARGV January 19, 2005, 2:34 pm
@ARGV vanished! April 29, 2005, 7:04 am
ARGV interpretation in s/// September 29, 2005, 12:01 pm
possible link/ARGV problem? November 2, 2005, 8:24 am
[Q] $ARGV, <>, and command-line Perl December 16, 2004, 6:43 pm
Documentation for shifting elements of @ARGV March 9, 2005, 11:27 pm
@ARGV not getting command line arguments March 22, 2005, 8:24 am

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap