=head1 NAME
-perlfaq7 - General Perl Language Issues ($Revision: 1.23 $, $Date: 2005/04/07 21:39:34 $)
+perlfaq7 - General Perl Language Issues ($Revision: 1.25 $, $Date: 2005/08/08 02:38:25 $)
=head1 DESCRIPTION
(contributed by brian d foy)
L<perlmod>, L<perlmodlib>, L<perlmodstyle> explain modules
-in all the gory details. L<perlnewmod> gives a a brief
+in all the gory details. L<perlnewmod> gives a brief
overview of the process along with a couple of suggestions
about style.
objects. See L<perlsub/"Pass by Reference"> for this particular
question, and L<perlref> for information on references.
-See ``Passing Regexes'', below, for information on passing regular
+See "Passing Regexes", below, for information on passing regular
expressions.
=over 4
The data in chunk of memory defined by C<$count> is private to
C<counter>.
- BEGIN {
- my $count = 1;
- sub counter { $count++ }
- }
+ BEGIN {
+ my $count = 1;
+ sub counter { $count++ }
+ }
- my $start = count();
+ my $start = count();
- .... # code that calls count();
+ .... # code that calls count();
- my $end = count();
+ my $end = count();
In the previous example, you created a function-private variable
because only one function remembered its reference. You could define
my $count = 1;
sub increment_count { $count++ }
sub return_count { $count }
- }
+ }
To declare a file-private variable, you still use a lexical variable.
A file is also a scope, so a lexical variable defined in the file