sweetblood has asked for the wisdom of the Perl Monks concerning the following question:
Now if I use 'or' in calling foo() like this:sub foo { my @bar = qw(one two three four); return @bar; }
All works as I expect, @foobar gets the list from foo()'s @bar, however if I use '||' like this:@foobar = foo() or warn "Yikes!\n";
Then I get the scalar value of @bar in @foobar.@foobar = foo() || warn "Yikes!";
I'm very confused. how does using '||' instead of 'or' change what is returned by a sub?
TIA
Sweetblood
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: '||' vs 'or' with subroutines
by diotalevi (Canon) on Nov 11, 2004 at 15:25 UTC | |
by sweetblood (Prior) on Nov 11, 2004 at 16:01 UTC | |
|
Re: '||' vs 'or' with subroutines
by demerphq (Chancellor) on Nov 11, 2004 at 15:30 UTC | |
|
Re: '||' vs 'or' with subroutines
by rev_1318 (Chaplain) on Nov 11, 2004 at 15:38 UTC | |
|
Re: '||' vs 'or' with subroutines
by Roy Johnson (Monsignor) on Nov 11, 2004 at 14:51 UTC | |
|
Re: '||' vs 'or' with subroutines
by hardburn (Abbot) on Nov 11, 2004 at 14:51 UTC | |
|
Re: '||' vs 'or' with subroutines
by PodMaster (Abbot) on Nov 12, 2004 at 11:08 UTC |