You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Brett Lee <br...@ndr.com> on 2000/06/22 17:03:52 UTC

my && param

Hello,
How should I correctly make "Param" assignments availble to function_2
and NOT to function_1 ???

#---------------------------
sub function_1 {
  blah
  blah
}

sub function_2 {
  my @array = param('This_Param');

  foreach (@array) {
    my @{$_} = param($_);     # ASSIGNMENT IN QUESTION
  }

  # HERE I NEED TO USE THE "@whatever" ARRAYS
  # BUT I DONT THINK THEY EXIST OUTSIDE THE "foreach (@array)" SCOPE
}
#---------------------------

-- 
Brett Lee 
Ned Davis Research Group
brett@ndr.com

Re: my && param

Posted by Peter Haworth <pm...@edison.ioppublishing.com>.
> 
> How should I correctly make "Param" assignments availble to function_2
> and NOT to function_1 ???
> 
> #---------------------------
> sub function_1 {
>   blah
>   blah
> }
> 
> sub function_2 {
>   my @array = param('This_Param');
> 
>   foreach (@array) {
>     my @{$_} = param($_);     # ASSIGNMENT IN QUESTION
>   }
> 
>   # HERE I NEED TO USE THE "@whatever" ARRAYS
>   # BUT I DONT THINK THEY EXIST OUTSIDE THE "foreach (@array)" SCOPE
> }
> #---------------------------

Try putting them in a hash:

sub function_2{
  my @array=param('This_Param');
  my %params;
  foreach(@array){
    @{$params{$_}}=param($_);
  }

  # Now, instead of print @whatever, do this:
  print @{$params{whatever}}; 
}


-- 
	Peter Haworth	pmh@edison.ioppublishing.com
"C++ gives me the willies. Physical willies. I take medication for it."
		-- Kurt Starsinic on p6p