>
> Go out of scope, yes. Destroyed, no. Want to test? No problem. Do
> the following in a perl script.
>
> my($funnything);
> print"Value of funnything is $funnything";
> $funnything="Uh oh... check this out";
>
> You'll find some interesting results on your second interation :-).
> Even funnier might be the folowing...
>
> dosomefunnystuff();
> sub dosomefunnystuff {
> my($funnystuff);
> if($funnystuff eq "funny") {
> dosomefunnystuff();
> }
> print "Funnystuff is $funnystuff";
> $funnystuff="funny";
> }
>
> Try that, and you will truely find out how memory inefficient modperl
> is :-). I haven't tested that second one, but based on what I know
> about how perl works... it should prove... interesting.
>
> Thanks,
> Shane.
Quick note about this: You'll have to hit the same process, so you
might have to reload a couple times for the effect to hit. Also
something maybe even funner...
my $i=0;
dosomefunnierstuff();
sub dosomefunnierstuff {
my $funnierstuff;
if($funnierstuff=~/funnier/) {
dosomefunnierstuff();
} else {
$funnierstuff="funnier".$i++;
}
print "Funnierstuff is $funnierstuff\n";
}
That proves the point a bit more clearly. It will show that each
layer of the "stack" keeps its own discreet copy of the variable.
That's why I've said before recursion!=good for modperl.
Personally... I LOVE recursive algorithms... but it just doesn't make
sense in a mod_perl enviro. If you do use recursion and have large
variables of strings for instance... you should pass by reference when
possible.., and you use "delete" at the bottom of the code block when
possible.
Thanks,
Shane.
>
> >
> > - Perrin