Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: map return to array reference

by kyle (Abbot)
on Jan 24, 2007 at 17:09 UTC ( #596292=note: print w/replies, xml ) Need Help??


in reply to map return to array reference

Your map is returning a list (Update Hmmm, maybe not so much). If you want a reference to an array containing that list, wrap it in square brackets:

my $files_to_send = [ map {"$stage/$_.pdf"} @{$self->_getGood()} ];

The reason you get Can't use string ("6") as an ARRAY ref is that the array returned by map, in a scalar context, is turned into the cardinality of the array, so $files_to_send gets the value 6.

I even went so far as to declare $files_to_send = []; like so, and I still get the same results.

This is the part that I don't understand. Setting $files_to_send to a reference to an empty array should give you no output in the code you have above. It really gives the same error, or it fails a different way?

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://596292]
help
Chatterbox?
[jdporter]: let me google that for me ;-)
[jdporter]: hex points explicitly to oct, which does the job. :-D
[jdporter]: omg, I f love Perl!
[choroba]: say unpack 'H*', pack 'B*', $mask =~ /0b([01]+)/;
[choroba]: use C instead of H to get the decimal number
[erix]: ( no love like f love )
[choroba]: f* love

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (9)
As of 2018-02-20 16:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    When it is dark outside I am happiest to see ...














    Results (272 votes). Check out past polls.

    Notices?