Greetings all,
I agree with Roy Johnson about the slashes. you are trying to make @results a reference on the left hand side, which is why you are getting the error.
Here are my suggestions for modifying your code.
my $command = sub { my @returnstring = $d->checklist( text => $text, list => [ @list ] + ); return \@returnstring; }; my $some_ref = &$command;
Now if you wanted the array from $d->checklist() to return as a reference itself you might try.
my $command = sub { my $returnstring = \($d->checklist( text => $text, list => [ @list + ] )); return $returnstring; }; my $some_ref = &$command;
However if you already have declared @returnstring outside of the scope of your anonymous sub and you wish to use this sub to modify it then you could simply do something like this...
my @returnstring; my $command = sub { @returnstring = $d->checklist( text => $text, list => [ @list ] ); };
again assuming that $d->checklist() returns an array.
A simple way to think of it is that references get assigned to something. So the \ is allowed on the right hand side only.
At least thats what works for me. :)
These examples are untested but I think, as Roy Johnson pointed out, that your slashes are the problem.

-InjunJoel
"I do not feel obliged to believe that the same God who endowed us with sense, reason and intellect has intended us to forego their use." -Galileo

In reply to Re: Probably an easy one - store command in variable. by injunjoel
in thread Probably an easy one - store command in variable. by rementis

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.