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

[email protected] ("Jan Dubois")
Newsgroups perl.perl5.porters
Organization ActiveState Software Inc
Message-ID <[email protected]>
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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.