Hi,
James Edward Gray II [mailto:[EMAIL PROTECTED] asked:
> I would like to add some code to a sub that only needs to be run the
> first time the sub executes, or before is fine. If I add an INIT { }
> block at the beginning of the sub, would that do it? Are there other
> ways? Thanks.
If you don't mind using code references, you could try this:
#!/usr/bin/perl -w
use strict;
my $fun;
$fun = sub {
print "Just initializing...\n";
$fun = sub {
print "Now it's the real deal\n";
};
};
foreach (qw( 1st 2nd 3rd )){
print "$_ call: ";
$fun->();
}
__END__
HTH,
Thomas
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]