local %ENV = %ENV; $ENV{TERM} = 'vt220';
No need to localize the entire hash to alter just one value. You can localize single elements of hashes and arrays:
{ local $ENV{TERM} = 'vt220'; `/usr/sbin/iptraf -s eth0 -B -L some.log`; }
Exiting the block will restore the old contents of the hash or array, making the element reappear if it was deleted:
my %letters = 'a'..'h'; my @nums = 0..8; { local $letters{'c'}; delete $letters{'c'}; local $nums[4]; @nums = (); } use Data::Dumper; print Data::Dumper->Dump ( [\%letters, \@nums], ['letters', 'nums'] ); __END__ $letters = { 'e' => 'f', 'c' => 'd', 'a' => 'b', 'g' => 'h' }; $nums = [ undef, undef, undef, undef, 4 ];
This is all documented in perlsub.
--
David Serrano
In reply to Re^2: Problem running IPTraf from Perl
by Hue-Bond
in thread Problem running IPTraf from Perl
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |