Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Question about defined loop

by ikegami (Patriarch)
on Mar 11, 2010 at 17:28 UTC ( [id://828101]=note: print w/replies, xml ) Need Help??


in reply to Question about defined loop

Depending on when you want to set $self->{_not_exposed_reason},
sub not_exposed_reason { my ($self, $not_exposed_reason) = @_; return $self->{_not_exposed_reason} = defined($not_exposed_reason) ? $not_exposed_reason : "No exposed reason"; }
or
sub not_exposed_reason { my ($self, $not_exposed_reason) = @_; if (defined($not_exposed_reason)) { return $self->{_not_exposed_reason} = $not_exposed_reason; } else { return "No exposed reason"; } }

Note that

defined(X) ? X : Y
can be written as
X // Y
since Perl 5.10.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://828101]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (4)
As of 2025-11-15 03:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What's your view on AI coding assistants?





    Results (72 votes). Check out past polls.

    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.