However, my question is: How can I disambiguate a method call on a string so that it is always resolved as a class method call, and not as a call on an IO instance?
You can't :) apparently filehandles rule the typeglob, thats why it hasn't been recommended for a long time
$ perl -fle " sub Snacks::Ahoy { q{Nom} } open Snacks, q{>}, \q{}; pri +nt $Snacks::{Ahoy}->() " Nom $ perl -fle " sub Snacks::Ahoy { q{Nom} } open Snacks, q{>}, \q{}; pri +nt bless(\(my$q=\{Snacks}),q{Snacks})->Ahoy " Nom $ perl -fle " sub Snacks::Ahoy { q{Nom} } sub Snacks { q{Rice} } print + Snacks::->Ahoy " Nom $ perl -fle " sub Snacks::Ahoy { q{Nom} } open Snacks , q{<}, \q{Rice} +; print Snacks::->Ahoy " Can't locate object method "Ahoy" via package "IO::File" at -e line 1.
In reply to Re: Prevent Strings From Being Interpreted As A File Handle
by Anonymous Monk
in thread Prevent Strings From Being Interpreted As A File Handle
by amon
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |