in reply to Re^3: design the open function
in thread design the open function

thanks for your reply Davido,
use warnings; use subs qw/ open /; sub open { print "Hello world!\n"; CORE::open($_[0],"d:\\input.txt") } 1;
i call the above module named open_temp.pm from the following file
use lib "d:\\"; use open_temp; open(SEL); print <SEL>;
will the above code good and efficient??
whether it will work for everything?

Replies are listed 'Best First'.
Re^5: design the open function
by davido (Cardinal) on May 10, 2006 at 08:02 UTC

    That won't work because you're not importing the version of open() defined within open_temp.pm into package main. You really should just read the perlsub document, like I linked to before. And honestly, I don't think you've followed my advice about really really really thinking about whether you actually need to do it this way. Just because Perl lets you override built-in functions doesn't mean you should. Why do you need an overridden open function? Why not just call your new function "myopen()"? Do you have to override for some good reason?


    Dave