Aaron_A has asked for the wisdom of the Perl Monks concerning the following question:

When I run the following programs (named args.pl) with ActiveState PERL (or under Unix):
#!/usr/bin/perl use warnings ; if ($#ARGV >= 0) {for ($n=0 ; $n<=$#ARGV ; $n++) {print("ARGV[$n]=$ARGV[$n]\n") ; } } else {print("No command line parameters found.\n") ; }
as follows:
> args.pl abc
the output is:
ARGV[0]=abc
But when I run it using StrawberryPerl 5.10.1 I get:
No command line parameters found.
Why? And what do I have to do to pick up the command line parameters?

Replies are listed 'Best First'.
Re: Picking up command line arguments with Strawberry Perl: ARGV
by ikegami (Patriarch) on Jan 27, 2010 at 19:16 UTC
    Your file association is broken.
    "C:\...\bin\perl.exe" "%1"
    but it should be
    "C:\...\bin\perl.exe" "%1" %*
    To fix:
    >assoc .pl .pl=Perl ---- \\\\ \\\\ vvvv >ftype Perl Perl="C:\...\bin\perl.exe" "%1" -------------------------- \\\\\\\\\\\\\\\\\\\\\\\\\\ \\\\\\\\\\\\\\\\\\\\\\\\\\ \\\\\\\\\\\\\\\\\\\\\\\\\\ vvvvvvvvvvvvvvvvvvvvvvvvvv >ftype Perl="C:\...\bin\perl.exe" "%1" %* Perl="C:\...\bin\perl.exe" "%1" %*
      This does not fix the issue.
Re: Picking up command line arguments with Strawberry Perl: ARGV
by Anonymous Monk on Jan 27, 2010 at 18:52 UTC
    But when I run it using StrawberryPerl 5.10.1 I get:

    Try

    perl file.pl args
    then go ahead and fix your ftype/assoc (type `help assoc' in cmd.exe )
Re: Picking up command line arguments with Strawberry Perl: ARGV
by Anonymous Monk on Jan 27, 2010 at 18:56 UTC
    perltidy -csc -otr -opr -ce -nibc -i=2 < prog.pl
    #!/usr/bin/perl -- use warnings; use strict; if (@ARGV) { for my $n ( 0 .. $#ARGV ) { print "ARGV[$n]=$ARGV[$n]\n"; } } else { print "No command line parameters found.\n"; }