in reply to Re: Overriding "-s", "-f" and other -X functions
in thread Overriding "-s", "-f" and other -X functions
Note that this only works if the thing that you're calling the -X on is an object of the overloaded class.
use warnings; use strict; { package Foo; use Data::Dump; use overload fallback=>0, '-X' => sub { dd @_; return 1 }; } my $foo = bless {}, 'Foo'; print -e $foo ? 'yes' : 'no', "\n"; my $bar = "doesnotexist"; print -e $bar ? 'yes' : 'no', "\n"; __END__ (bless({}, "Foo"), "e", "") yes no
|
|---|