in reply to hash referencing...best approach?
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?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: hash referencing...best approach?
by Anonymous Monk on Nov 24, 2003 at 21:32 UTC | |
by Roy Johnson (Monsignor) on Nov 24, 2003 at 22:08 UTC | |
by Anonymous Monk on Nov 25, 2003 at 00:06 UTC | |
by Roy Johnson (Monsignor) on Nov 25, 2003 at 02:51 UTC | |
by Roger (Parson) on Nov 25, 2003 at 00:25 UTC |