faqts : Computers : Programming : Languages : Perl

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

Entry

I have a variable in a new function in a Perl module, I want that varaible to retain its value.

Dec 1st, 2004 09:21
Nat Tuck, Kunal Kapoor,


package SomePackage;
use warnings FATAL => 'all';
use strict;
use Exporter;
our @ISA = qw(Exporter);
our @EXPORT_OK = qw(my_sub);
# Define the variable outside of any
# sub. If you want it to be accessable
# from outside the module, use "our"
# instead of "my".
my $lasting_variable;
sub my_sub ($) {
    my ($arg) = @_
    $lasting_variable .= $arg;
}