Wim De Hul wrote:
>
> Hashes are hard to understand (regarding on the questions in this
> list...). I have also a question:
> Why doesn't this work? I get a synthax error?
>
> foreach $index (sort keys %IfType{$router}) {
> print " Interface : $IfType{$router}{$index}\n";
> print " Card type : $IfCardType{$router}{$index}\n";
> print " Postition : $IfPos{$router}{$index}\n";
> print " Speed : $IfSpeed{$router}{$index}\n";
> print " Description : $IfDescr{$router}{$index}\n";
> print "\n";
> }
>
What's the error message or the exact misbehaviour ?
Do you use "use strict" and "use warnings" ?
I'm not sure, but the syntax of
foreach $index (sort keys %IfType{$router}) {
^^^
seems to be strange.
I assume that %IfType is a hash of hashes.
If so in $IfType{$router} is a reference to a hash.
It's possible to dereference it with a leading % (before the $),
so I would expect:
foreach $index (sort keys %{$IfType{$router}}) {
...
}
Best Wishes,
Andrea
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]