Brent Clark am Dienstag, 2. August 2005 14.08:
> Hi all
>
> I my thanks to all whom have tried to help me earlier, but alas, I still
> cant seem to get this right.
> I know this gonna kick me because it will be a stupid small mistake.
use strict; use warnings;
at the beginning of the script would have helped you with something like
Can't use string ("Standard Room") as a HASH ref while
"strict refs" in use at ./test11.pl line 15.
As I didn't realize in my last answer, you imagine an inexistent additional
level in your data structure.
> my ($ref_hash, $fileName) = @_;
>
> foreach my $roomCode ( keys %{ $ref_hash->{$fileName} }){
>
> foreach my $rmData ( keys %{
> $ref_hash->{$fileName}->{$roomCode} } ){
> print $ref_hash->{$fileName}->{$roomCode}->{$rmData};
> #Nothing
> gets displayed
> }
>
> print does not display anything.
>
> Here is my Data::Dumper info
>
> $VAR1 = {
> 'Grac01' => {
> 'StndRm' => 'Standard Room',
> 'Suite' => 'Suite',
> 'Pent' => 'Penthouse'
> },
>
> If anyone could be so kind to help, it would greatfully be appreciated.
---- script ---
#!/usr/bin/perl
use strict; use warnings;
my $struct= {
'Grac01' => {
'StndRm' => 'Standard Room',
'Suite' => 'Suite',
'Pent' => 'Penthouse'
}
};
sub enum {
my ($ref_hash, $fileName) = @_;
foreach my $roomCode ( keys %{ $ref_hash->{$fileName} }){
print $ref_hash->{$fileName}->{$roomCode}, "\n";
}
}
enum ($struct, 'Grac01');
---- script end ---
This prints:
Standard Room
Penthouse
Suite
joe
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>