You've muddled several things, here. The hash should be assigned with a list, not a block. There's no reason to create $s, since you're just throwing it away. You can return the reference by just sayingsub make_session { my ($u,$a,$s)=@_; %session_hash={ user=>$u, dept=>$a }; $s=\%session_hash; }
as the last line. You don't say where the result of make_session goes, and you don't declare %session_hash as a lexical in the sub, which means you're going to be returning a reference to the same thing every time.\%session_hash;
I'm guessing that here you want to chomp $line2.while (my $line2=<HTTP>) { chomp;
I think I know what you want to do, but I'm not sure: Create a hash entry for each unique session, and associate a filename with it. Then, when you're reading the log files, you'll parse out the session name, and write (append) the line onto the associated file. Is that right?
In reply to Re: hash referencing...best approach?
by Roy Johnson
in thread hash referencing...best approach?
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |