in reply to Re^3: Scope Issue
in thread Scope Issue

I tried || and // and they both worked. Thanks to everyone for your contribution!

Replies are listed 'Best First'.
Re^5: Scope Issue
by GrandFather (Saint) on Mar 15, 2011 at 21:03 UTC

    Note that || and // have different effects when the variable being tested is false! // only tests for undefined. || tests for any false value. ||= will replace 0 or '' with the right hand side value where //= will only replace undef with the right hand side value.

    //= behaves like:

    $var = $defaultValue if ! defined $var;

    ||= behaves like:

    $var = $defaultValue if ! $var;
    True laziness is hard work