in reply to Is there any way to override "file test operator"?
You can overload the operator with the overload pragma, although this only works if your package is being used as a class. Also only works on Perl v5.12 or later. Example:
package MyFileTest; use overload ( '-X' => \&myfiletest, ); sub new { ... } ... package main; my $file = MyFileTest->new($filename); if(-f $file){ ... }
See also the filetest pragma.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Is there any way to override "file test operator"?
by Anonymous Monk on Aug 09, 2011 at 07:55 UTC |