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

Re: my if?

Bernie Cosell
July 1, 2003 07:40
Re: my if?
Message ID:
On 1 Jul 2003 at 10:30, Ronald J Kimball wrote:

> On Tue, Jul 01, 2003 at 05:15:09PM +0300, Vladi Belperchinov-Shabanski wrote:
> >   my $id = 1 if $_ == 3;


> This was an accidental feature that is now kept for backwards
> compatibility, because some programmers have used it to create static
> variables.  It's best to avoid it, however.

It is undefined behavior [even though it works currently in every version 
of Perl] and so it IS best to avoid it.  What I don't understand is why 
the powers-that-be provide so much resistance to putting in a simple 
'static' declaration that would work the same way, only be defined-and-
legal.  e.g.,:
   sub x
   {   static $vbl ;

Oh well, I guess re-opening that wound isn't much fun...

Bernie Cosell                     Fantasy Farm Fibers     Pearisburg, VA
    -->  Too many people, too few sheep  <--     Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About