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

Re: shift doesnt shift

by mje (Curate)
on Nov 27, 2008 at 13:43 UTC ( [id://726407]=note: print w/replies, xml ) Need Help??


in reply to shift doesnt shift

works for me so long as the argument is true i.e.,

./service.pl file.txt

works but of course the following do not:

./service.pl '' ./service.pl 0

for the obvious reason that the empty string and 0 are not true.

Replies are listed 'Best First'.
Re^2: shift doesnt shift
by joec_ (Scribe) on Nov 27, 2008 at 13:51 UTC
    $@ is empty. Im just using the name of the command line arg to read in a file of data. Replacing || with or didnt work. Like i said, the same code works in a different script. What else could cause a shift to die?

    TIA. Joe.

      We need to see more code.

      You wrote: X or Y
      1) Y is evaluated when X is false
      2) X is empty (aka undef, aka false)
      1+2=3) Therefore Y (the die) is performed.

      So, what is the problem here? It is doing exactly what you told it to. If you want it to die on some other condition than the shift giving 0/undef/''/etc, then you need to specify that condition in your code.

      Try specifying what to shift: $var = shift @array to ensure you're shifting the right array.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (4)
As of 2024-03-29 12:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found