< Perl Programming < Keywords

The reset keyword

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

  reset EXPRESSION
  reset

Examples

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

This article is issued from Wikibooks. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.