in reply to Re^3: Problems with HOHOH modification
in thread Problems with HOHOH modification

$HOHOH{'Alphakey2'}->{'Betakey2'} ||= {}; This was the syntax I was looking for. I havenīt seen this type of syntax before. Thank You. Is it possible to use in on something else? If var is not assigned to assign two to it.. $var||=2;

Replies are listed 'Best First'.
Re^5: Problems with HOHOH modification
by GrandFather (Saint) on Feb 13, 2008 at 19:54 UTC

    Yes!

    || returns the value that dictated the outcome of the operation - either the left hand value if it was true, or the right hand value if the left is false. See perlop and keep in mind that Perl has useful ideas about what constitutes true and false. undef, '', '0' and 0 are all false. Consider:

    print undef || "undef is false", "\n"; print 0 || "0 is false", "\n"; print '' || "'' is false", "\n"; print '0' || "'0' is false", "\n"; print '0xxx' || "'0xxx' is false", "\n"; print 'false' || "'0xxx' is false", "\n"; print '1' || "'0xxx' is false", "\n";

    Prints:

    undef is false 0 is false '' is false '0' is false 0xxx false 1

    Perl is environmentally friendly - it saves trees