Hello fellow monks, I am trying to create a hash of keys from usernames, and each key would contain a hash of details. When I do it this way it works fine:
#!/usr/bin/perl
use warnings;
use strict;
my %users;
$users{mulander}->{email} = 'netprobe@gmail.com';
print "$users{mulander}->{email}\n";
I would like to store the data using dbmopen so I tried:
#!/usr/bin/perl
use warnings;
use strict;
dbmopen my %users,'users',664;
$users{mulander}->{email} = 'netprobe@gmail.com';
print "$users{mulander}->{email}\n";
dbmclose %users;
But when I do that, I keep getting this error:
Can't use string ("HASH(0x1865480)") as a HASH ref while "strict refs"
+ in use
I wonder why does this work fine when used on a ordinardy hash and fails when I open the hash via dbmopen? What am I doing wrong? Is a dbmopen hash different than an ordinary hash? And if so should I use another method to tie this data structure to a file? ( maybe Tie::Scalar or something? ).
I gone through perldoc and Beginning Perl and unfortunetly did not find the anwser, maybe one of you brothers could enlighten me.
Thanks in advance.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.