[Israel.pm] List of all contexts in Perl

Yuval Kogman nothingmuch at woobling.org
Sun May 30 09:18:47 PDT 2010


More clarification:

On 30 May 2010 13:32, Mikhael Goikhman <migo at homemail.com> wrote:

> On 30 May 2010 12:09:52 +0300, Offer Kaye wrote:
> >
> > I'm not sure I understand what "boolean context" means, or any of the
> > others you listed. Except for the ".." operator does any of Perl's
> > built-in functions operate differently inside an "if" test for
> > example, in terms of the value returned (assuming you assign it to
> > something)?
>

In the context of Want it just checks if the retop operation involves a
boolean operator such that SvTRUE of the return value is the only thing ever
used.

    my $foo = foo();
    if ( $foo ) { # not boolean context


    if ( foo() ) { # boolean context



>  > Looked at another way, you can do anything you want with the return
> > value of for example "localtime", but in the end it will still return
> > either a scalar or list, regardless of what you do with those values
> > later on, right?
>

Correct, the SvTRUE(sv) done by the conditional opcode is kind of like a
method call in this case (and really a method call when overloading is
used), Want merely checks to see if the next and only thing done to the
return value is something specific like that.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.perl.org.il/pipermail/perl/attachments/20100530/d382fa9a/attachment-0001.htm 


More information about the Perl mailing list