I am not able to understand why following code is not working.
<%method getvivekBox>
<%args>
$BoxName
</%args>
<%perl>
return {
type => 'vivek',
};
</%perl>
</%method>
<%method getAll>
<%args>
$BoxGroup
$indexex
</%args>
<%perl>
my $x = map { $m->comp('SELF:getvivekBox' , BoxName => "$BoxGroup-$_"); } @$indexex;
return $x;
</%perl>
</%method>
I am calling getAll with arguments , box and (1..10). It is returning 11 but expected behavior for me it should return 10 elements.
map on a list produces another list. You are assigning the result of the map to a scalar, thus getting the number of elements assigned to $x.
Change $x to @x, or put [] around the map (to make $x an array reference).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With