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

Thank you sir, the code worked great! If I could ask, I understand placing the grep results into the array. Could you explain the "if (@found)" and the next line of code ?

Replies are listed 'Best First'.
Re^3: IF and GREP Question
by NetWallah (Canon) on Sep 18, 2013 at 05:09 UTC
    "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.

      "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.