[ back to toc ]

Subroutine

Date: 2002/05/28 10:10

Q:
Hello Peter,

At the very beginning of Subroutine is
the code as belows.
Could you please explain to me how these
works? With my ...

sub display_frontpage
{
my %numbers = ();
my $output = "";

Please let me hear you.

*NAME-DELETED*
A:
sub display_frontpage

starts the definition of the subroutine. The next block aka: the code
between { and } is the executable core of the subroutine.

The keyword 'my' tells the interpreter that the variables '%numbers' and
'$output' are local variables and have nothing to do with the variables
that have the same name globally.

The code

my %numbers = ();
my $output = "";

declares these local variables and at each call to the subroutine the code
also initializes the value to

() -> empty hash
"" -> empty string

regards,
Peter

[ back to toc ]