in reply to reset function

You are creating two types of variables:

my $var = 10; # This is a lexical variable. $van = 5; # This is a package global.

If you were dealing only with lexicals, you could do this:

{ my $var = 10; my $van = 5; print "\$var = $var; \$van = $van\n"; } # Here, $var and $van don't exist.

But you're talking about resetting just those variables that start with 'v'. Don't think that way. Think in terms of using a hash:

use strict; use warnings; my %hash; $hash{var} = 10; $hash{van} = 5; print "var = $hash{var}; van = $hash{van}\n"; delete hash{$_} for grep { /^v/ } keys %hash; print "var = $hash{var}; van = $hash{van}\n";

If you don't want to delete the keys, you could also just do this:

$hash{$_} = undef for grep { /^v/ } keys %hash;

Dave