Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

Re^2: Sequential defined-or operators

by plobsing (Friar)
on Jan 15, 2008 at 02:39 UTC ( #662415=note: print w/ replies, xml ) Need Help??

in reply to Re: Sequential defined-or operators
in thread Sequential defined-or operators

Thats all fine and good until your default value is ask_user(). Then this fails due to eager evaluation. // fixes this fortunately.

Comment on Re^2: Sequential defined-or operators
Select or Download Code
Replies are listed 'Best First'.
Re^3: Sequential defined-or operators
by ikegami (Pope) on Jan 15, 2008 at 03:28 UTC
    It took me a second to understand that you are referring to the short-circuiting nature of //. If you needed the short-circuiting behaviour pre-5.10, here's one solution:
    sub first(&@) { my $cb = shift(@_); for (@_) { my $i = ref eq 'CODE' ? $_->() : $$_; my $rv; $rv = $cb->() for $i; return $i if $rv; } return; } my $theme = first { defined } \$global_config->{modes}{$current_mode}{theme}, \$theme_config->{current_theme}, \&ask_user, \'none';

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (14)
As of 2015-11-30 20:40 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (782 votes), past polls