<?xml version="1.0" encoding="windows-1252"?>
<node id="171080" title="Re: @_ still mystifies me" created="2002-06-02 18:49:00" updated="2005-07-19 14:07:41">
<type id="11">
note</type>
<author id="49599">
tadman</author>
<data>
<field name="doctext">
Disappointments:
&lt;BLOCKQUOTE&gt;&lt;CODE&gt;# Unfortunate scalar conversion
my @foo = @_ || @bar;

# Unfortunate error, not DWIM-compatible
my @foo = @_;
@foo ||= @bar;
&lt;/CODE&gt;&lt;/BLOCKQUOTE&gt;
Although there are many good solutions posted here, how about a bad one?
&lt;BLOCKQUOTE&gt;&lt;CODE&gt;my @bar = qw[ dog cat frog ];

sub foo 
{
        my @foo = grep{length}(@_, (!@_ &amp;&amp; @bar));

        print join(',', @foo),"\n";
}
&lt;/CODE&gt;&lt;/BLOCKQUOTE&gt;
Hey, it works, but it's quite brittle. If you even think about changing the order of the parameters, you're into SCALAR land.</field>
<field name="root_node">
170918</field>
<field name="parent_node">
170918</field>
</data>
</node>
