in reply to Passing different values into subroutines

To pass non-scalars into subroutines you can use references. For example, to pass an array you can do the following.
my @array1 = ( 1, 2, 3, 4 ); my @array2 = ( 5, 6, 7, 9 ); printArrays( \@array1, \@array2 ); sub printArrays { my ( $first, $second ) = @_; print "@$first @$second\n"; }
You can use references to pass hashes as well, you can even pass subroutines if you feel like it.

Update: To apply this to your situation...
sub printEachExpt { my ( $expNames, $outputPath ) = @_; my $total = @$expNames; print "The output path is $outputPath.\n"; print "The experiment files are:\n"; for ( 0 .. $#$expNames ) { print "$outputPath/$expNames->[$n]\n"; } return( $expNames, $outputPath); }
That should be what you want to do... untested...

Update: oh and you don't need that line with $total in there...

Replies are listed 'Best First'.
RE: RE: Passing different values into subroutines
by Adam (Vicar) on Aug 31, 2000 at 21:48 UTC
    sub printEachExpt { my @expNames = @{$_[0]}; # De-reference the array. my $outputPath = $_[1]; print "The output path is $outputPath.\n"; print "The experiment files are:\n"; print "$outputPath/$_\n" for @expNames; } # And to call it: printEachExpt( \@myExp, $mypath ); # -------------^ the \ means a reference to the @myExp