Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re^2: ARGV question

by olus (Curate)
on Aug 18, 2008 at 22:13 UTC ( #705085=note: print w/ replies, xml ) Need Help??


in reply to Re: ARGV question
in thread ARGV question

I got curious about that behavior of the zero length result, went looking and now humbly share my findings.

In chapter 3 of Programming Perl it is said that

The equal and not-equal operators return 1 for true and "" for false (3.12)

and

The && and || operators differ from C's in that, rather than returning 0 or 1, they return the last value evaluated. (3.14)

so, @ARGV is greater than 0 and passes, eq fails and returns '', and thus && returns the last value evaluated, which is ''.


Comment on Re^2: ARGV question
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://705085]
help
Chatterbox?
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: (7)
As of 2014-12-18 11:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (50 votes), past polls