Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Problem with ActivePerl 5.6.1 and @ARGV

by mooseboy (Pilgrim)
on Dec 13, 2002 at 11:12 UTC ( #219548=perlquestion: print w/replies, xml ) Need Help??

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

Fellow monks,

I am experiencing a problem using ActivePerl 5.6.1 under Win2K -- all my command-line scripts which use @ARGV have stopped working. For example, if I call the following with argvtest.pl frodo sam gollum it prints a single blank line:

#!/usr/bin/perl use warnings; use strict; foreach my $item (@ARGV) { print "$item was found in \@ARGV\n"; }

However, if I hard-code @ARGV into the script like so: @ARGV = (qw/frodo sam gollum/); it works ok. I did a reinstall of ActiveState 5.6.1 but the problem remains. The only thing I can think of that might be connected is that I recently installed a trial version of DzSoft's Perl Editor 5.3, but then decided I didn't like it and deinstalled it. If anyone can shed any light on this I would be most grateful!

Thanks, mooseboy

Replies are listed 'Best First'.
Re: Problem with ActivePerl 5.6.1 and @ARGV
by simonflk (Pilgrim) on Dec 13, 2002 at 11:30 UTC

    Sounds like your file associations might be messed up. Try running the script as "perl argvtest.pl frodo sam gollum"

    Check this faq for instructions on fixing the file associations. (too long to copy and paste here)

    -- simonflk

Re: Problem with ActivePerl 5.6.1 and @ARGV
by theorbtwo (Prior) on Dec 13, 2002 at 11:41 UTC

    It does, indeed, sound like your file association for perl is messed up -- it should look like "perl %*", not "perl %1".


    Warning: Unless otherwise stated, code is untested. Do not use without understanding. Code is posted in the hopes it is useful, but without warranty. All copyrights are relinquished into the public domain unless otherwise stated. I am not an angel. I am capable of error, and err on a fairly regular basis. If I made a mistake, please let me know (such as by replying to this node).

Re: Problem with ActivePerl 5.6.1 and @ARGV
by demerphq (Chancellor) on Dec 13, 2002 at 13:19 UTC
    I think as the OP's have said that its the file association settings. The way you can double check is
    perl -e "print qq(@ARGV)" Foo bar baz
    Also if you are on win32 then the shebang line is superfluous and IMO confusing.

    --- demerphq
    my friends call me, usually because I'm late....

      Thanks to all for the help ... I checked out settings->control panel->folder options->file types and there was clearly some sort of problem. The Perl icon showed a wrong description and the buttons were greyed out, so I created a new one as per the faq link from simonflk. Now, when I do perl -e "print qq(@ARGV)" Foo bar baz I get Foo bar baz, but the original problem remains -- my scripts that use @ARGV are broken, but the ones that don't still work fine. If the problem was just with the file association, then am I right in thinking that *all* my scripts would have been broken, not just the ones using @ARGV? Any further advice much appreciated!

      <Cheers, mooseboy

        If the problem was just with the file association, then am I right in thinking that *all* my scripts would have been broken, not just the ones using @ARGV? Any further advice much appreciated!

        No, only the programs that use @ARGV would suffer. Assuming the problem is that your file association says "when you run script.pl, execute 'perl <scriptname>'". That means that if you type:

        c:\> script.pl foo bar baz
        What gets run is actually
        perl script.pl
        So if a program doesn't use @ARGV, it doesn't care it's being omitted.

        Does that make sense?

        -- Dan

        Please to show us what the file association says for a PL file. Mine shows
        "E:\Perl\bin\perl.exe" "%1" %*
        Also have you rebooted? I know it _shouldnt_ be required. But this is windows after all....

        --- demerphq
        my friends call me, usually because I'm late....

Re: Problem with ActivePerl 5.6.1 and @ARGV
by Popcorn Dave (Abbot) on Dec 14, 2002 at 04:34 UTC
    I believe that the other monks here are correct in what they've said about calling the program.

    I just ran your code on a win98 box, using DZSoft's Perl editor to put the code in, and ActiveState Perl 5.6.1 build 631 and it ran perfectly.

    If you're not running build 631, then you may want to upgrade it.

    There is no emoticon for what I'm feeling now.

      Latest AS build is 633.

      :-)

      --- demerphq
      my friends call me, usually because I'm late....

Re: Problem with ActivePerl 5.6.1 and @ARGV
by batkins (Chaplain) on Dec 13, 2002 at 11:31 UTC
    wfm in 5.8.0. i don't have a copy of 5.6.1 to test it. upgrading might do the trick.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (7)
As of 2021-06-25 10:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What does the "s" stand for in "perls"? (Whence perls)












    Results (135 votes). Check out past polls.

    Notices?