in reply to Syntax Question
Pretty easy, isn't it? But if we wan't to give two arrays, we got a problem - this isn't possible. Here we could use references:sub ShowIt { print join(',',@_); } @Foo = (1,2,3); &ShowIt(@Foo);
Here we go:sub ShowIt { my $Array1 = $_[0]; my $Array2 = $_[1]; print "Array 1: ".join(',',@$Array1)."\n"; print "Array 2: ".join(',',@$Array2)."\n"; } @Foo = (1,2,3); @Bar = (4,5,6); &ShowIt(\@Foo,\@Bar);
You could also create references to so-called anonymus Scalars, Arrays and Hashs, but I'll leave this to the Perldoc-document...@Cities_DE = ('Berlin','Hannover','Hamburg'); @Cities_US = ('New York','Miami','Las Vegas'); %Cities = ('DE' => \@Cities_DE, 'US' => \@Cities_US); print "Where are you?".join(',',@$Cities{$Country});
|
|---|