silent11 has asked for the wisdom of the Perl Monks concerning the following question:
Below is the code in question:
which returnsmy $files_to_send = map {"$stage/$_.pdf"} @{$self->_getGood()}; print map {"$_\n"} @{$files_to_send};
I have a sub _getGood() that collects the *good* files I want to process/send in my script. This sub returns an array:Can't use string ("6") as an ARRAY ref while "strict refs" in use at M +oduleName.pm line 136.
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:sub _getGood { my ($self,@args) = @_; print "_getGood()", Dumper $self->{_good}; return @{$self->{_good}}; }
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.$VAR1 = [ 'C21622241', 'C21594007', 'C21619147', 'C21572375', 'C21611603', 'C21617783' ];
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 :)
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: map return to array reference
by ikegami (Patriarch) on Jan 24, 2007 at 17:05 UTC | |
by merlyn (Sage) on Jan 24, 2007 at 17:49 UTC | |
by Limbic~Region (Chancellor) on Jan 24, 2007 at 18:21 UTC | |
Re: map return to array reference
by liverpole (Monsignor) on Jan 24, 2007 at 17:05 UTC | |
Re: map return to array reference
by Ieronim (Friar) on Jan 24, 2007 at 17:06 UTC | |
Re: map return to array reference
by kyle (Abbot) on Jan 24, 2007 at 17:09 UTC | |
Re: map return to array reference
by johngg (Canon) on Jan 24, 2007 at 17:06 UTC | |
Re: map return to array reference
by davorg (Chancellor) on Jan 24, 2007 at 17:06 UTC |
Back to
Seekers of Perl Wisdom