Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
To the left of the ::= are my keys and to the right the element to be stored in the array for each key. When I print out my HOA I get<S> ::= <SS> <W> ::= <V> <V> ::= <SS>
Basically it storing the keys and array as a stack where its stored first in goes at the bottom and then each new set of key and corresponding array is stored above that. My question is how can I get it to store into the hash in the order of the input...In other words I want the keys and correspoinding array stored in the exact way the input is given. Here is the code I am using...I would really appreciate any help....thanks alot.<V> ::= <SS> <W> ::= <V> <S> ::= <SS>
I apologize but it doesnt seem like im using the tags rightwhile($line=<>) { chomp $line; ($head, $prod) = split /\s*::=\s*/, $line; $head=~ s/^(\s+)//; $head=~ s/\s+$//; $prod=~ s/^(\s+)//; $prod=~ s/\s+$//; if($bool==0) { $start=$head; $bool=1; } push(@{$hasharr{$head}}, $prod); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: hash property
by pg (Canon) on Oct 15, 2003 at 04:43 UTC | |
|
Re: hash property
by davido (Cardinal) on Oct 15, 2003 at 05:51 UTC | |
by Anonymous Monk on Oct 15, 2003 at 06:05 UTC | |
|
Re: hash property
by Roger (Parson) on Oct 15, 2003 at 04:48 UTC |