develooper Front page | perl.perl5.porters | Postings from November 1999

with all this local() talk...

Thread Next
From:
Jeff Pinyan
Date:
November 16, 1999 13:50
Subject:
with all this local() talk...
Message ID:
Pine.GSO.4.10.9911161632530.24181-100000@crusoe.crusoe.net
Is this idea I just had REALLY farfetched?  I sounds to me like it would
take some serious work to incorporate:

  {
    local select(FH);
    $| = 1;
  }
  # former handle now select()ed

  {
    local chdir($specified_dir) if $specified_dir;
    find(...);
  }
  # original directory is now current one again

Obviously (as pudge_ said), "I do not like it; keep same things same and
different things different," the function name would be different... I
don't know if it's a feasable thing to do.  It would just be less of a
headache for some people, I guess.

  {
    my $oldfh = select NEWFH;
    $| = 1;
    select $oldfh;
  }

  {
    local select(NEWFH);
    $| = 1;
  }

  select((select(NEWFH),$|=1)[0]);

I mean, for *me* if I were learning the language, I'd stick with the
middle one if it existed.

I say it would be difficult to implement because example:  chdir() returns
success or failure, while select() returns the currently selected
filehandle, so this sister function to local wouldn't just be some
shorthard for the A((A(B),C)[0]) construction.

And that's that.  I can't tell how foolish an idea it is.

In fact, right now, I'm trying to think of specific cases where you'd use
it.  Not coming up with many. :)

-- 

  MIDN 4/C PINYAN, USNR, NROTCURPI     http://www.pobox.com/~japhy/
  jeff pinyan: japhy@pobox.com     perl stuff: japhy+perl@pobox.com
  "The Art of Perl"               http://www.pobox.com/~japhy/book/      
  CPAN ID: PINYAN  http://www.perl.com/CPAN/authors/id/P/PI/PINYAN/
  PerlMonth - An Online Perl Magazine     http://www.perlmonth.com/


Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About