develooper Front page | perl.perl5.porters | Postings from June 2010

RE: [perl #75734] filehandle methods interfere with internal implementation details

Thread Previous
From:
Jan Dubois
Date:
June 14, 2010 18:25
Subject:
RE: [perl #75734] filehandle methods interfere with internal implementation details
Message ID:
01f001cb0c29$911b50b0$b351f210$@activestate.com
On Mon, 14 Jun 2010, Nicholas Clark (via RT) wrote:
> 
> There needs to be a way to call methods on classes that isn't subject to
> "filehandles take priority". Otherwise the internals can be tricked,
> accidentally or deliberately.

I kind of expected that suffixing the classname with "::" would help (which
is already needed if you have a sub with the same name as the class:

  $ perl -E 'package foo; sub bar { say "baz" } package main; sub foo { "xyzzy" } foo->bar'
  Can't locate object method "bar" via package "xyzzy" (perhaps you forgot to load "xyzzy"?) at -e line 1.

  $ perl -E 'package foo; sub bar { say "baz" } package main; sub foo { "xyzzy" } foo::->bar'
  baz

But it doesn't help with the "filehandles take priority" case:

  $ perl -E 'package foo; sub bar { say "baz" } package main; BEGIN { fileno foo } foo::->bar'
  Can't locate object method "bar" via package "IO::Handle" at -e line 1.

I wonder if it should...

Cheers,
-Jan


Thread Previous


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