Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

Re^3: IF and GREP Question

by NetWallah (Canon)
on Sep 18, 2013 at 05:09 UTC ( #1054587=note: print w/replies, xml ) Need Help??

in reply to Re^2: IF and GREP Question
in thread IF and GREP Question

"if ()" imposes a scalar context.

An array in a scalar context returns the number of elements.

If the array is empty, "if (@found)" sees undef or zero , which is FALSE in perl.

If the array has values, "if(@found)" sees a non-zero value, which is TRUE in perl.

             My goal ... to kill off the slow brain cells that are holding me back from synergizing my knowledge of vertically integrated mobile platforms in local cloud-based content management system datafication.

Replies are listed 'Best First'.
Re^4: IF and GREP Question
by jwkrahn (Monsignor) on Sep 18, 2013 at 06:10 UTC
    "if ()" imposes a scalar context.

    Actually it imposes a boolean context, which is basically the same as scalar context.

    "if (@found)" sees undef or zero

    An array in boolean context cannot be undef.    In fact, defined doesn't work with arrays anymore.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1054587]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (2)
As of 2018-01-23 04:37 GMT
Find Nodes?
    Voting Booth?
    How did you see in the new year?

    Results (238 votes). Check out past polls.