develooper Front page | perl.perl5.porters | Postings from September 2000

strict 'refs' and subroutine symbolic refs

From:
Daniel Chetlin
Date:
September 17, 2000 05:45
Subject:
strict 'refs' and subroutine symbolic refs
Message ID:
20000917054344.A7295@ilmd
Taking a break from debugging overload.pm, I was trolling the bugdb...

http://bugs.perl.org/perlbug.cgi?req=bidmids&bidmids=19991128.002

And I decided that I'm confused.

  [~] $ perl -Mstrict=refs -wle'sub f{print "f"}&{"f"}'
  Can't use string ("f") as a subroutine ref while "strict refs" in use at
  -e line 1.
  [~] $ perl -Mstrict=refs -wle'sub f{print "f"}$b="f";&$b'
  Can't use string ("f") as a subroutine ref while "strict refs" in use at
  -e line 1.
  [~] $ perl -Mstrict=refs -wle'sub f{print "f"}$b=\&{"f"};&$b'
  f
  [~] $ perl -Mstrict=refs -wle'sub f{print "f"}sub b{&{"f"}}b()'
  Can't use string ("f") as a subroutine ref while "strict refs" in use at
  -e line 1.
  [~] $ perl -Mstrict=refs -wle'sub f{print "f"}sub b{goto &{"f"}}b()'
  f

I don't necessarily think any behavior should be changed, but I
certainly think some documentation is in order. I can't for the life of
me figure out what the exceptions and the rules are here, and I also
can't find mention of it in the docs at all.

-dlc



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