use warnings; use strict; # true x in 'v'..'z'; # false xx in 'v'..'z'; # but variables aren't barewords my $x='x'; in->$x('v'..'z'); package in; use Data::Dump qw/pp/; our $AUTOLOAD; sub AUTOLOAD { (my $LHS= $AUTOLOAD) =~ s/in:://; #print pp [$LHS, @_]; my $res = grep {$LHS eq $_ } @_; my $not =""; $not =' not' unless $res; warn "$LHS$not @_"; return $res; }
/usr/bin/perl -w /tmp/in.pl x in v w x y z at /tmp/in.pl line 35. xx not in v w x y z at /tmp/in.pl line 35. x in v w x y z at /tmp/in.pl line 35. Compilation finished at Wed Aug 26 13:51:16
Cheers Rolf
(addicted to the Perl Programming Language and ☆☆☆☆ :)
Je suis Charlie!
In reply to Re: Create a new operator, get LHS (indirect method + autoload)
by LanX
in thread Create a new operator, get LHS
by stevieb
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |