root/ext_comm.pl
| Revision 37cbe43bf668696d2f26324ca62752e777b57d2b, 314 bytes (checked in by Theo Schlossnagle <jesus@omniti.com>, 12 years ago) | |
|---|---|
| |
| Line | |
|---|---|
| 1 | #!/usr/bin/perl |
| 2 | |
| 3 | my %commhist; |
| 4 | my %commcache; |
| 5 | |
| 6 | sub cache_command { |
| 7 | my $command = shift; |
| 8 | my $expiry = shift; |
| 9 | my $now = time; |
| 10 | if($commhist{$command}>$now) { |
| 11 | return $commcache{$command}; |
| 12 | } |
| 13 | $commcache{$command} = `$command`; |
| 14 | $commhist{$command} = $now + $expiry; |
| 15 | return $commcache{$command}; |
| 16 | } |
| 17 | |
| 18 | 1; |
Note: See TracBrowser for help on using the browser.
