Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

mocking overloading filetest operator callback -f -d -e -X

by Anonymous Monk
on Dec 18, 2013 at 09:33 UTC ( [id://1067613]=perlquestion: print w/replies, xml ) Need Help??

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I thought this would work
#!/usr/bin/perl -- BEGIN { package OOO; sub new { my( $pkg, $path ) = @_; bless \$path, $pkg; } sub filetest { warn "its fake @_\n"; 'fake' } use overload '-X' => \&filetest; $INC{'OOO.pm'} = __FILE__; } use strict; use warnings; use OOO; -f OOO->new('.'); __END__ Operation """": no method found, argument in overloaded package OOO at + - line 6.

I don't understand, what did I miss?
http://perl5.git.perl.org/perl.git/blob?f=gv.c#l3022
http://perl5.git.perl.org/perl.git/blob?f=t/op/filetest_stack_ok.t#l17
http://perl5.git.perl.org/perl.git/blob?f=t/op/magic.t#l617
http://perl5.git.perl.org/perl.git/blob?f=lib/overload.t#l1840

Replies are listed 'Best First'.
Re: mocking overloading filetest operator callback -f -d -e -X
by Athanasius (Archbishop) on Dec 18, 2013 at 12:24 UTC

    A Super Search on “Operation """"” finds this 2009 thread: overload op requires stringify overload ?? Applying Bloodnok’s “fix of sorts” —

    #! perl -- BEGIN { package OOO; sub new { my( $pkg, $path ) = @_; bless \$path, $pkg; } sub filetest { warn "its fake @_\n"; 'fake' } use overload '-X' => \&filetest, fallback => 1; $INC{'OOO.pm'} = __FILE__; } use strict; use warnings; use OOO; -f OOO->new('.');

    gives:

    22:15 >perl 804_SoPW.pl its fake OOO=SCALAR(0x1c15434) f 22:19 >

    Is that what you were wanting?

    Anyway, hope it helps,

    Athanasius <°(((><contra mundum Iustus alius egestas vitae, eros Piratica,

Re: mocking overloading filetest operator callback -f -d -e -X
by kcott (Archbishop) on Dec 18, 2013 at 14:31 UTC

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1067613]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (6)
As of 2024-03-28 23:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found