I have about 40 possible departments, so I just wrote a small sub routine

sub write_it{ my ($dept,$output)=@_; my $output_file=$dept."_access.log"; open DATA,">> $output_file")||die ("unable to open $output_file $!\n") +; print DATA $output."\n"; close DATA; }


This works pretty great, I was able to read through one of the access logs and create the specific files in about 4 minutes. The one problem I have now is appending the user_code to the end of the access log line.

I tried to change the way I 'write' to the session_hash while reading the session logs to :
$session_hash($sessio_id}{$user}=$dept_code;
But this just screwed me up later down the line when I reading through the access logs. For this part I currently have:
open (HTTP,$access_log)||die ("unable to open $access_log $!\n"); while (my $line2=<HTTP>) { chomp $line2; my @fields=split /\s+/, $line2; my $session=@fields[6]; my $session=substr($session,(index($session,"?")+12),(inde +x($session,"|"))-(index($session,"?")+12) ); if (length($session) ==52) { &write_it($session_hash{$session},$line2); }
I tried to incorporate the user_code part into this and ended up getting the hash address everywhere. In other words, my file names became hash addresses and my user_code values where null. Surely I am missing something minor here. Thanks for all the help thus far, it has proven most superb.

In reply to Re: Re^3: hash referencing...best approach? by Anonymous Monk
in thread hash referencing...best approach? by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.