Perl Programming/Keywords/reset

Previous: require Keywords Next: return

The reset keyword

edit

The reset command clears variables and resets ?? at the end of a loop. It is generally used in a continue block. The EXPRESSION is understood as a list of single characters, where hyphens are allowed for ranges. It always returns 1.

All arrays and variables beginning with these characters in the current package are reset to their original state. Without the EXPRESSION, the one-time searches in the current package (?pattern?) are reset so that they can match again.

Before searching for a file with the .pm extension, reset searches first for a file with .pmc extension, loading it instead of the .pm file, if found.

Setting EXPRESSION to EXPRESSION is not recommended, as it wipes out the @ARGV and @INC arrays, and the %ENV hash.

Syntax

edit
  reset EXPRESSION
  reset

Examples

edit
reset 'X'; # reset all X variables
reset 'A-z'; # not recommended, as it wipes out @ARGV, %ENV, and @INC
reset 'a-z'; # reset all lower-case variables
reset; # reset ?one-time? searches

See also

edit
Previous: require Keywords Next: return