in reply to Syntax Question

You could use references to make your code easier in many ways. You may know this:
sub ShowIt { print join(',',@_); } @Foo = (1,2,3); &ShowIt(@Foo);
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 { 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);
Here we go:
  • Foo and Bar are Arrays which are defined as usual.
  • ShowIt is called and the two Arrays are passed, but if you would pass them directly, there would be no chance to seperate which value was from which Array. They are passed as references which means: "Use the Array found at the memory location x" and references are indicated by prefixing the thing (scalar, array or hash) by a \.
  • ShowIt now puts each argument into a variable (not necessary, just for visibility)
  • The JOINs dereference (= follow the reference) the arguments. They say: Interpret the content of $Array1 as a @ (Array)
  • References make many things easier, just think of:
    @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});
    You could also create references to so-called anonymus Scalars, Arrays and Hashs, but I'll leave this to the Perldoc-document...