develooper Front page | perl.fwp | Postings from July 2003

RE: my if?

Pense, Joachim
July 3, 2003 03:59
RE: my if?
Message ID:
> I think your training is to fault. Consider that files are a lexical
> scope as well, as if their were braces. Were subs not visible outside
> of a scope, we wouldn't have modules and objects as we have them now.

Files are different.

> > Is there a sensible way of combining the advantages, that 
> is: defining subs
> > outside of blocks that share static variables anyway? 
> Whatever I can think
> > of would be even worse than version one (more complicated, 
> less intuitive,
> > more error-prone), so has anyone else thought of a concept? 
> You could always use a package variable - but those would be visible
> to other subs as well. 

This would definitely not be the solution

> But since you don't want to group subs in a scope anyway...

I think using objects that have the shared variables as attributes of
objects for which the subs are methods, but this is of course overkill for
small programs.

Joachim Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About