Am I the only one who thinks it's dumb for there to be no built-in way to clear only user defined variables, to avoid the problem with the reset function clearing stuff like @INC?
I have a 3200 line script that I wrote using global variables, but I decided to turn it into a server type thing that runs continuously, waiting for someone to give it a command. Unfortunately, now I must clear extra variables and I'm not sure which ones so I want to clear them all. Reloading the script would be less efficient and it would require an extra file so I could bypass the administrator authentication routine that I want to be executed only once.
I came up with:
@file = <IN>;
$FILE = join (' ',@file);
while ($FILE =~ s/[\@\$][a-zA-Z]\w+//)
$ONE_VAR = $&;
$ALL_VAR .= $ONE_VAR =~ /\$/ ? "$ONE_VAR='';" : "$ONE_VAR=();";
So now I could add lines to ignore whatever variables I want to not be cleared. Is there a better way? Would this be suitable for the Snippets section?