[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] (de)referencing and DBM files



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

At 5:02 PM -0600 8/17/98, Stephen M. Gray wrote:

} Howdy all,
}
} How does one go about dereferencing an array stored as a value in a DBM
} hash? The following script gives me an "uninitialized value" error (on the

You're trying to store references to arrays, and you can't do that in a DBM
file  (see page 145 and Chapter 10 of "Advanced Perl Programming").

You need to look at either Data::Dumper or Storable.  MacPerl versions of
both are available at Chris Nandor's web site.

} marked line). I've read through the referencing  sections of MPPE and the
} Camel book and neither seems to address this. The code, if modified to not
} use the DBM file, works fine so I'm led to believe the problem has to do
} with the DBM file. Is there an additional step I need to be taking?
}
}
} use AnyDBM_File;
} use Fcntl;
}
} $pathToDBMFile = "stingray:Desktop Folder:userPass.dbm";
} @steve = ("blue", "grape", "43", "31");
} @darin = ("green", "orange", "265", "33");
} @chris = ("yellow", "apple", "86", "30");
}
} tie(%userArray, 'AnyDBM_File', $pathToDBMFile, O_CREAT | O_RDWR, 0666)
}   or die ("Couldn't create DBM file! $!");
}  $userArray{"steve"} = \@steve;
}  $userArray{"darin"} = \@darin;
}  $userArray{"chris"} = \@chris;
} untie(%userArray);
}
} tie(%myArray, 'AnyDBM_File', $pathToDBMFile, O_RDONLY, 0666)
}   or die ("Can't open for reading DBM File! $!");
}  foreach $keyVal (keys (%myArray)){
}   print "value: ${$myArray{$keyVal}}[1]\n"; #<- problem is here!
}  }
} untie(%myArray);
}
}
}
} Thanks,
} Steve
}
}
} ***********************************
} Stephen M. Gray
} Webmaster
} Trendmasters - www.trendmasters.com



- -----
Paul J. Schinder
schinder@pobox.com

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBNdi1oVZaVc52j0XhEQKNrgCfZbQ8vwHE1TdtYt5fUJU59rl93rsAmwRD
7gpxS2EY8J8qggsG2LlAzFnw
=sdYE
-----END PGP SIGNATURE-----

***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch