Perl reset Function
Description
This function resets (clears) all package variables starting with the letter range specified by EXPR. Generally only used within a continue block or at the end of a loop. If omitted, resets ?PATTERN? matches.
Variables that have been declared using the my() function will not be reset.
Using reset() can reset system variables you may not want to alter-like the ARGV and ENV variables.
Syntax
Following is the simple syntax for this function −
reset EXPR reset
Return Value
This function returns 1.
Example
Following is the example code showing its basic usage −
#!/usr/bin/perl -w
my $var = 10;
$van = 5;
print "Var value = $var, Van value =$van\n";
# Now reset all variables who name starts with 'v'
reset('v');
print "Var value =$var, Van value =$van\n";
When above code is executed, it produces the following result −
Var value = 10, Van value = 5 Var value = 10, Van value =
perl_function_references.htm
Advertisements