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

What's wrong with @ARGV - or with me?

by karlgoethebier (Abbot)
on Jun 12, 2013 at 12:17 UTC ( [id://1038453]=perlquestion: print w/replies, xml ) Need Help??

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

Hi, please take a look at this little snippet:

use Data::Dumper; my $dir=$ARGV[0]; print Dumper(\@ARGV); print $dir; print shift; __END__ D:\tmp\Scripts>z1.pl foo $VAR1 = []; Use of uninitialized value $dir in print at D:\tmp\Scripte\z1.pl line +12. Use of uninitialized value in print at D:\tmp\Scripte\z1.pl line 14. D:\tmp\Scripts>perl z1.pl foo $VAR1 = [ 'foo' ]; foofoo D:\tmp\Scripte>

Big surprise!

It works on Linux, Mac and XP.

OS is Windows7 with ActivePerl.

Whats going on here?

Thank you and regards, Karl

«The Crux of the Biscuit is the Apostrophe»

Replies are listed 'Best First'.
Re: What's wrong with @ARGV - or with me?
by choroba (Cardinal) on Jun 12, 2013 at 12:18 UTC
    Wrong file association/registry setting not passing arguments?
    لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ

      ...file association is OK. Regards, Karl

      «The Crux of the Biscuit is the Apostrophe»

        .file association is OK.

        Doubtful. Your symptoms are exactly those of a windows system with mis-configured associations.

        Please post your output from running assoc .pl and ftype Perl


        With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
        Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
        "Science is about questioning the status quo. Questioning authority".
        In the absence of evidence, opinion is indistinguishable from prejudice.

        Your .pl file association is correct in regards to executing the script, but is incorrect/incomplete because it doesn't "see" the args passed to the script.

        Look up the HKEY_CLASSES_ROOT\Applications\perl.exe\shell\open\command entry in the registry. The value should be "C:\Perl\bin\perl.exe" "%1". I suspect that yours is missing the "%1"

        EDIT: Sorry, I just saw your .pl association post. It looks correct.

Re: What's wrong with @ARGV - or with me?
by Utilitarian (Vicar) on Jun 12, 2013 at 12:40 UTC
    Assuming your file association is correct
    Windows 7 Enterprise with Perl 5_16 from active state
    C:\Users\utillitarian>type test.pl #!/usr/bin/perl $dir=$ARGV[0]; use Data::Dumper; print Dumper(\@ARGV); print "$dir\n"; print shift; C:\Users\utillitarian>perl test.pl foo $VAR1 = [ 'foo' ]; foo foo C:\Users\utillitarian>
    Perl's file association is to gvim on this box though

    print "Good ",qw(night morning afternoon evening)[(localtime)[2]/6]," fellow monks."

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (5)
As of 2024-03-29 13:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found