Jump to content

Perl Programming/Keywords/my

From Wikibooks, open books for an open world
Previous: msgsnd Keywords Next: ne

The my keyword

[edit | edit source]

The my keyword is used before a variable declaration and makes the variable lexically in this block, file, or eval. If the user wants that more than one variable is declared in this way, parenthesis are required.

Syntax

[edit | edit source]
  my VARIABLE_LIST
  my TYPE VARIABLE_LIST
  my VARIABLE_LIST : ATTRIBUTES
  my TYPE VARIABLE_LIST : ATTRIBUTES

Examples

[edit | edit source]
  my ( undef, $min, $hour ) = localtime;
  []
  my $dollars = 123;

See also

[edit | edit source]
Previous: msgsnd Keywords Next: ne