Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
Below is the code in question:
my $files_to_send = map {"$stage/$_.pdf"} @{$self->_getGood()}; print map {"$_\n"} @{$files_to_send};
which returns
Can't use string ("6") as an ARRAY ref while "strict refs" in use at M line 136.
I have a sub _getGood() that collects the *good* files I want to process/send in my script. This sub returns an array:
sub _getGood { my ($self,@args) = @_; print "_getGood()", Dumper $self->{_good}; return @{$self->{_good}}; }
I have the Dumper in there for good measure, just to see that I am indeed returning what I want return, an array. The Dumper output prints the following:
$VAR1 = [ 'C21622241', 'C21594007', 'C21619147', 'C21572375', 'C21611603', 'C21617783' ];
At one point in time a variation of this was working, now it's not and I don't see the problem. Besides assigning map to a scalar, I can't see what is amis. I even went so far as to declare $files_to_send = []; like so, and I still get the same results.

ideas? I can get this to work by assigning to an array as opposed to a reference, but that would require extra lines of code :)

Spread Firefox

In reply to map return to array reference by silent11

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, 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, 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.
  • Log In?

    What's my password?
    Create A New User
    and all is quiet...

    How do I use this? | Other CB clients
    Other Users?
    Others musing on the Monastery: (9)
    As of 2018-06-21 00:06 GMT
    Find Nodes?
      Voting Booth?
      Should cpanminus be part of the standard Perl release?

      Results (117 votes). Check out past polls.