I am working on making a module to test my Perl skills. I am trying to return an object with hashes in it that you can access through the object, but I can't access the hashes.
Here is my code:
return bless {
'hits' => { %hits },
'hosts' => { %hosts },
'hitsByDate' => { %hitsByDate },
'hitsByTime' => { %hitsByTime },
'hitsByDateTime' => { %hitsByDateTime },
'visitsByDate' => { %visitsByDate },
'visitsByTime' => { %visitsByTime },
'visitsByDateTime' => { %visitsByDateTime },
'methods' => { %methods },
};
I am calling it like this:
my $al = new Apache::LogParser;
my $log = $al->getAccessLog();
my %hits = $log->hits;
The module is Apache::LogParser and the getAccessLog() routines is returing the first section of code with the bless and hashes. The problem is it isn't returning hashes when I call
$log->hits amd I can't figure out why.
I've tried returning it without blessing it and many other ways, but it just won't go. Do any monks know what I am missing or am doing wrong. I know the variables are filled because i can print them directly from the module. I just can't seem to get it to work.
Thanks for your time
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.