What does "||=" mean?

Hi,
Can someone please give an explaination of the following line:

$starttime ||= $created

Exactly what does the "||=" expression mean, I haven't been able to find it in any documentation that I've got.
incAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Kim RyanIT ConsultantCommented:
The OR assignmnent operator. It means take the result of
$starttime || $created (logical OR)
and assign the result to $starttime .

0
ozoCommented:
perldoc perlop

  C-style Logical Or

    Binary "||" performs a short-circuit logical OR operation. That
    is, if the left operand is true, the right operand is not even
    evaluated. Scalar or list context propagates down to the right
    operand if it is evaluated.

    The `||' and `&&' operators differ from C's in that, rather than
    returning 0 or 1, they return the last value evaluated. Thus, a
    reasonably portable way to find out the home directory (assuming
    it's not "0") might be:

        $home = $ENV{'HOME'} || $ENV{'LOGDIR'} ||
            (getpwuid($<))[7] || die "You're homeless!\n";

    In particular, this means that you shouldn't use this for
    selecting between two aggregates for assignment:

        @a = @b || @c;              # this is wrong
        @a = scalar(@b) || @c;      # really meant this
        @a = @b ? @b : @c;          # this works fine, though

    As more readable alternatives to `&&' and `||' when used for
    control flow, Perl provides `and' and `or' operators (see
    below). The short-circuit behavior is identical. The precedence
    of "and" and "or" is much lower, however, so that you can safely
    use them after a list operator without the need for parentheses:

        unlink "alpha", "beta", "gamma"
                or gripe(), next LINE;

    With the C-style operators that would have been written like
    this:

        unlink("alpha", "beta", "gamma")
                || (gripe(), next LINE);

    Use "or" for assignment is unlikely to do what you want; see
    below.


  Assignment Operators

    "=" is the ordinary assignment operator.

    Assignment operators work as in C. That is,

        $a += 2;

    is equivalent to

        $a = $a + 2;

    although without duplicating any side effects that dereferencing
    the lvalue might trigger, such as from tie(). Other assignment
    operators work similarly. The following are recognized:

        **=    +=    *=    &=    <<=    &&=
               -=    /=    |=    >>=    ||=
               .=    %=    ^=
                     x=

    Note that while these are grouped by family, they all have the
    precedence of assignment.

    Unlike in C, the assignment operator produces a valid lvalue.
    Modifying an assignment is equivalent to doing the assignment
    and then modifying the variable that was assigned to. This is
    useful for modifying a copy of something, like this:

        ($tmp = $global) =~ tr [A-Z] [a-z];

    Likewise,

        ($a += 2) *= 3;

    is equivalent to

        $a += 2;
        $a *= 3;
0
guadalupeCommented:
Not to detract from the answers above which were good but the simple straight answer is that

$starttime ||= $created

means set $starttime equal to $created
unless $starttime is already defined/true remember that defined/true in perl is defined as other than 0 or the empty string ("") or any expression which evaluates to  such.  For a goo explanation of undefined/false read pages 20-21 in the Camel Book (Get a copy if you don't already own one.  It is the best book to learn Perl clear complete and concise.)
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
incAuthor Commented:
Thanks, just what I wanted for an answer.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Perl

From novice to tech pro — start learning today.