Scot Needy wrote: > > Hi; Hello,
> 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. > > I hope this is enough code to example my problem. > -------------- snip ---------------------- > foreach (@wwwlogs) { > %time=(); > ($wwwname,$cust,$YYMMDDay) = split('\.',$_); The first argument to split is a regular expression. my ( $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('\|',$_); my ( $pid, $hhmmss, $host, $custname, $custsub, $site ) = split /\|/; > # print(SPLITVARS= $hhmmss,$host,$custname,$custsub,$site\n); > $time=>{$custname}=>{$custsub}=>{$site}=>{$YYMMDDay} = $hhmmss; You are using the => operator which is the same as a comma when you should be using the -> operator to dereference hash references. $time{$custname}->{$custsub}->{$site}->{$YYMMDDay} = $hhmmss; Which could also be written as: $time{$custname}{$custsub}{$site}{$YYMMDDay} = $hhmmss; > } etc etc etc You can simplify things if you store the log file names in @ARGV instead of @wwwlogs. @ARGV = @wwwlogs; my %time; while ( <> ) { my ( $wwwname, $cust, $YYMMDDay ) = split /\./, $ARGV if $. == 1; chomp; # Walk through log file and look for our string. my ( $pid, $hhmmss, $host, $custname, $custsub, $site ) = split /\|/; # print(SPLITVARS= $hhmmss,$host,$custname,$custsub,$site\n); $time{$custname}{$custsub}{$site}{$YYMMDDay} = $hhmmss; # etc etc etc if ( eof ) { close ARGV; %time = (); } } __END__ John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]