Probs with @ARGV

T

tim

I'm reasonably new to perl (activeperl v5.6.1) and I'm having a problem with
@ARGV. I have a batch file that calls my perl script with the arguments of
"c:\temp\blah" "user" (the quotes are inherited from another program).
However the perl script thinks that this is a single argument and seems to
lose some of the quotes. Example:

perl -w incoming.pl "c:\temp\blah" "user"

produces

Arg. 0: c:\temp\blah" user

from

#!d:/perl/bin/perl.exe -w
my $num=0;
foreach (@ARGV) {
print "Arg. $num: $_\n";
$num++;
}

I would be grateful if anyone could explain why this is and if poss how to
get around it. I've looked at other post but couldn't find a solution.

thanks
 
A

Andre Wisniewski

I would be grateful if anyone could explain why this is and if poss how
to
get around it. I've looked at other post but couldn't find a solution.

thanks

I'm using Perl 5.8.3 on Win2k and can't reproduce this error.
 
A

Andre Wisniewski

Arg. 0: c:\temp\blah" user
It looks as if you surrend "c:\temp\blah user", not "c:\temp\blah" "user".
 
B

Brian McCauley

tim said:
I'm reasonably new to perl (activeperl v5.6.1) and I'm having a problem with
@ARGV. I have a batch file that calls my perl script with the arguments of
"c:\temp\blah" "user" (the quotes are inherited from another program).
However the perl script thinks that this is a single argument and seems to
lose some of the quotes. Example:

perl -w incoming.pl "c:\temp\blah" "user"

Are you sure that you have reproduced that line verbatim? Seems to
work OK here.

This sounds more likely to be a question about batch files than about
Perl.

Please produce a minimal but complete program (in this case a batch
file) that you have actually run and found to reproduce the symptoms
you describe. Post it in it's entirity unaltered. Post also the
version of the batch file interpreter you are using.

Ideally you should do this in a newsgroup that deals with the language
(or OS) in question but since I'm not 100% sure this isn't Perl
related I guess it would be OK to post here too.

--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
 
A

A. Sinan Unur

I'm reasonably new to perl (activeperl v5.6.1) and I'm having a
problem with @ARGV. I have a batch file that calls my perl script
with the arguments of "c:\temp\blah" "user" (the quotes are inherited
from another program). However the perl script thinks that this is a
single argument and seems to lose some of the quotes. Example:

This is most likely not about perl but the batch file or the shell you are
using. Do you see different results depending on whether you run the Perl
script from the command line or the batch file?

#! perl

use strict;
use warnings;

print "$_\n" for @ARGV;

__END__

C:\Home> perl t.pl "c:\temp\blah" "user"
c:\temp\blah
user

C:\Home\asu1> perl -v

This is perl, v5.8.4 built for MSWin32-x86-multi-thread
 
G

gnari

tim said:
perl -w incoming.pl "c:\temp\blah" "user"

produces

Arg. 0: c:\temp\blah" user

this is consistent with the command line:
perl -w incoming.pl "c:\temp\blah"" user"

are you sure you are reporting this correctly ?

gnari
 
B

Bob Walton

gnari said:
this is consistent with the command line:
perl -w incoming.pl "c:\temp\blah"" user"


Actually, no, at least not on Windoze 98SE -- any whitespace after the
"" is suppressed. Probably a bug. I'm not able to reproduce the OP's
reported result even allowing for simple typos.


....
 
J

Justin H.

Bob said:
Actually, no, at least not on Windoze 98SE -- any whitespace after the
"" is suppressed. Probably a bug. I'm not able to reproduce the OP's
reported result even allowing for simple typos.

What if there's a trailing \ on the path? i.e.

perl -w incoming.pl "c:\temp\blah\" "user"

I don't have perl installed on a Windows machine here, so I can't test
it, unfortunately.

Justin H.
 
G

gnari

you are right. i only tested it without the extra space
What if there's a trailing \ on the path? i.e.

perl -w incoming.pl "c:\temp\blah\" "user"

I don't have perl installed on a Windows machine here, so I can't test
it, unfortunately.

confirmed !

gnari
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,778
Messages
2,569,605
Members
45,238
Latest member
Top CryptoPodcasts

Latest Threads

Top