souravdas has asked for the wisdom of the Perl Monks concerning the following question:
Is this code correct? If so, how do we execute this program and how would we know that this code is doing caching activity?my %cache; sub first_line { my $filename = shift; return $cache{$filename} if exists $cache{$filename} open FILE,$filename or return ""; my $line=<FILE>; $cache{$filename}=$line; return $line; }
janitored by ybiC: Retitle from less-than-descriptive "Hello Monks!!!!" to improve site search results
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Cache Subroutine Return Value
by dragonchild (Archbishop) on Aug 11, 2004 at 14:46 UTC | |
by jdporter (Paladin) on Aug 11, 2004 at 15:03 UTC | |
by dragonchild (Archbishop) on Aug 11, 2004 at 15:06 UTC | |
|
Re: Cache Subroutine Return Value
by Roger (Parson) on Aug 11, 2004 at 16:02 UTC | |
|
Re: Cache Subroutine Return Value
by graff (Chancellor) on Aug 12, 2004 at 01:53 UTC | |
|
Re: Cache Subroutine Return Value
by adrianh (Chancellor) on Aug 12, 2004 at 09:35 UTC |