sean_mis@mail.misinc.net wrote: > > >> I've just sent to CPAN a new module, Mac::FileSpec::Unixish. It > >> should be in <http://www.perl.com/CPAN/authors/id/S/SB/SBURKE/>; if > > > >If you are going to create a module that does Unix<->Macintosh > >filesystem mapping, why not override open(), opendir(), etc. to > >translate them transparently? > > How would one override the filetest operators (functions?) like -s $foo? > BTW, I've never overridden any core functions, or used overload.pm, but > looking at overload.pm, it doesn't list the filetesters as things you can Your right. I don't see a way to override the filetest operators. Either I havn't looked in the right place, or that really stinks. The overload.pm module is not for redefining the standard perl functions, its for C++ like overloaded operators. For example, if you have a class and you want someone to be able to add two objects together and come up with another object as the result. $blue = new Color 'blue'; $red = new Color 'red'; $purple = $blue + $red; The recipe for overriding built in functions is buried in the perlsub documentation file. For overriding the built in functions, you simply define a similarly named function in your module, and put it into your @EXPORT_OK list. (Putting it in @EXPORT being considered rather antisocial.) @EXPORT_OK = qw(&open &opendir &stat); sub open (*;$){ my($fh,$unixname) = @_; my $nativname; if(defined $unixname) { $nativname = nativize($unixname); } else { # handle single arg open(filename) correctly # since the filehandle has to be an identifer, it contains no # path separators. $nativname = (*{$fh} =~ /::(\w+)$/); } CORE::open($fh,$nativname); } When open() is exported it replaces the built in function in the module that imported it. ***** Want to unsubscribe from this list? ***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch