in reply to Create a new operator, get LHS
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!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Create a new operator, get LHS (indirect method)
by Eily (Monsignor) on Aug 26, 2015 at 14:40 UTC | |
by LanX (Saint) on Aug 28, 2015 at 12:43 UTC | |
by Eily (Monsignor) on Aug 28, 2015 at 12:57 UTC |