geostorm.org


UTC 07:26:33
Monday
5/21/2012



May 2012
SuMoTuWeThFrSa
  12345
6789101112
13141516171819
20212223242526
2728293031  
       

welcome

Scalars, Arrays, Hashes, and multi-dimensional arrays and hashes



Simple scalar:
$s = "hello";

Simple array:
@a = ("color", "name", "hair");

Simple hash:
%h = ( "color", "red", "name", "bob", "hair", "black");
Same as:
%h = (
"color" => "red",
"name" => "bob",
"hair" => "black"
);


Multi-dimensional arrays:
$properties{"colors"} = [ "blue", "red", "green", "brown", "orange", "yellow" ];


$properties{"person"} = {
"vehicle" => ["sedan", "coupe", "SUV", "truck", "wagon"],
"name" => ["nancy", "joe", "bob", "lisa", "lee"],
"hair" => ["brown", "black", "gold", "red", "none"],
"home" => ["colonial", "multi-family", "apartment", "condo", "co-op", "trailer", "tent"],
};

same as:
$properties{"person"}{"vehicle"}[0] = "sedan";
$properties{"person"}{"vehicle"}[0] = "coupe";
$properties{"person"}{"vehicle"}[0] = "SUV";
etc...
This method, a complex multi-demensional array can have individual values added or changed just like a simple scalar.

Mixed multi dimensional arrays and hashes:
Hash:
%x = (
"a", "1",
"b", "2",
"c", "3",
"d", ['z', 'x', 'y']
);


$z = $x{d};
@z = @$z;
print "$_, " for @z;