Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: shift @ARGV not working

by blue_cowdawg (Monsignor)
on May 09, 2013 at 18:47 UTC ( #1032817=note: print w/ replies, xml ) Need Help??


in reply to shift @ARGV not working

#!/usr/bin/perl -w use strict; foreach my $i(0..$#ARGV){ printf "\$ARGV[%d] = \"%s\"\n",$i,$ARGV[$i]; } while(my $arg=shift @ARGV){ printf "%s\n",$arg; } # # -------------- 8< snip! 8<------------- $ ./shifty.pl a b c d e f g $ARGV[0] = "a" $ARGV[1] = "b" $ARGV[2] = "c" $ARGV[3] = "d" $ARGV[4] = "e" $ARGV[5] = "f" $ARGV[6] = "g" a b c d e f g
I think the issue you are a having is you didn't shift prior to setting $argument.


Peter L. Berghold -- Unix Professional
Peter -at- Berghold -dot- Net; AOL IM redcowdawg Yahoo IM: blue_cowdawg


Comment on Re: shift @ARGV not working
Download Code
Replies are listed 'Best First'.
Re^2: shift @ARGV not working
by Anonymous Monk on May 09, 2013 at 19:15 UTC

    Howdy blue_cowdawg,
    How could you miss that? The issue he was having is variable scope issue. How does the OP think he would be able to print the variable, when it was scoped to the if block?
    Moreover, if the OP has used strict and warnings, he would have seen the red gauge
    I think you need a break from the keyboard. You are working to hard...

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (12)
As of 2015-07-28 18:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (258 votes), past polls