Scot Needy wrote:
> Hi;
>
>  Trying to crate a nested hash from variables parsed out of log files
> but as I am a "Beginner Perl' coder it is failing terribly. The basic
> question is given you have 5 variables how would you make a nested
> hash.
>
> Thanks !
> Scot
>
> I hope this is enough code to example my problem.
> -------------- snip ----------------------
> foreach (@wwwlogs) {
> %time=();
> ($wwwname,$cust,$YYMMDDay) = split('\.',$_);
> open (LOG, $_ ) || die "Can't open $_!: $! \n";
>       while (LOG>) {
>       chomp;
>      # Walk through log file and look for our string.
>    ($pid,$hhmmss,$host,$custname,$custsub,$site,$junk) =
>    split('\|',$_); # print(SPLITVARS=
>      $hhmmss,$host,$custname,$custsub,$site\n);
> $time=>{$custname}=>{$custsub}=>{$site}=>{$YYMMDDay} = $hhmmss;
>
>       } etc etc etc

People have offered you some fine corrections to your code, but
I wonder if this is what you really want? The hash is very deeply
nested and is only necessary if you need to access you data this way.
Also I think you may well have multiple times per date to store, so
that subsequent times from the log file will simply overwrite
what you have already. Perhaps this is of some help:

    my $custsite = "$custname|$custsub|$site";
    my $time= "$YYMMDDay:$hhmmss";

    $time{$custsite}[$i++], $time;
    ( equivalent to 'push @{$time{$custsite}}, $time' )

i.e. an array of date/times for each customer site.

Don't copy this code verbatim, I'm trying to describe a
data structure rather than write functional code.

Cheers,

Rob






-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to