Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change

strawberry win10 no ARGV

by twyce (Initiate)
on Dec 14, 2019 at 22:15 UTC ( #11110152=perlquestion: print w/replies, xml ) Need Help??

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

I have windows 10, which I am new to. 
I have installed Strawberry Perl, which I am new to. 
I find that the scripts are not reading @ARGV. Period. 
Is there a setting? 
Is there a trick? 
Thanks much. 

Replies are listed 'Best First'.
Re: strawberry win10 no ARGV
by stevieb (Canon) on Dec 14, 2019 at 22:22 UTC

    Can you please post your code so we can see what you're trying to do, and how?

    Strawberry Perl handles command line arguments perfectly fine. Here's an example:

    use warnings; use strict; if (@ARGV != 3){ print "Program requires 3 arguments\n"; exit; } my ($one, $two, $three) = @ARGV; print "arg1: $one, arg2: $two, arg3: $three\n";


    > perl Program requires 3 arguments > perl 1 2 3 arg1: 1, arg2: 2, arg3: 3

    If you require anything more elaborate than sending in a small number of simple args, there's the Getopt::Long distribution.

      I am mostly interested in calling from another script. 
      I've tried qx, backticks, and system. 
      So Eventually I tried simply from the command line, like. " 09 12 34likj" 
      No dice. 
      My code is basically
      my $i = 0 ; 
      for ( @ARGV ) {
       $i++ ; 
       print "i:$i for argv $_\n" ; 
      print "$i is the final index of argv\n" ; 
      All my scripts work fine in win7 + activeperl

        your file association is wrong. You need %* after the "%1" in the command your association runs.

Re: strawberry win10 no ARGV
by choroba (Archbishop) on Dec 14, 2019 at 22:22 UTC
    How do you run the scripts? Do you click on them, or do you run them from a command line?

    Also, please don't use PRE or CODE tags for normal text. See <pre> Versus <code> Tags for details.

    map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]
      Normally I click on a perl script and it calls a 2nd script, successfully passing args via qx() and successfully getting the output. I also tried simply typing in the name of the script to a cmd window and put the args after it. The script did not see the command line args.

        Have you tried running your second script as "perl arg1 arg2 ..." instead of " arg1 arg2 ..."? You might need to add the full path to the Perl binary, which you can normally get from $^X (or Config's $Config{perlpath}, as documented in the first link). Also note my node here in regards to the potential issues with using qx//.

Re: strawberry win10 no ARGV
by Anonymous Monk on Dec 15, 2019 at 09:02 UTC

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://11110152]
Approved by Corion
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (4)
As of 2020-07-02 13:15 GMT
Find Nodes?
    Voting Booth?

    No recent polls found