Mark Sargent said: > Hi All, > > am new to Perl. I'm followig this tutorial, > > http://www.cs.unc.edu/~jbs/resources/perl/perl-basics/variables.html > > and am confused as to why the below shows examples with $ and some with > % at the beginning of the statement. When it says, "Perl uses the > "percent" symbol and curly braces with respect to the name of an > associative array as a whole". Am I to assume that either is fine, when > defining associative arrays.? Cheers.
I can see why you are confused, that whole tutorial is confusing, not to mention outdated (I think someone already did). > $aAA{"A"} = 1; # creates first row of assoc. array > $aAA{"B"} = 2; # creates second row of assoc. array <move confusing part> > %aAA = ("A", 1, "B", 2); # same as first two stmts., above Maybe better to look at it this way: %hash = ("Apple" => "Red", "Banana" => "Yellow", "Orange" => "Orange"); Now, when you want the value of Banana we look at the scalar (single entity) of the hash: print "My bananas are $hash{'Banana'}.\n"; Now to add a new "key"=>"value" pair $hash{"Blueberries"} = "Blue"; There are many good, Perl5 examples and tutorials out there, this one comes to mind: http://www.codebits.com/p5be/ and perl.com has a lot of useful stuff, if you don't mind digging about, as well as CPAN.org, although, maybe a bit more cryptic. Have fun, I know I am. :) -- Scott -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>