in reply to Re: Create a new operator, get LHS
in thread Create a new operator, get LHS

> There here's a notation which at least looks similar to infix - method call:

> $var->in(@list)

> ...

> Not very tingly. Sorry about that.

so why not

$var->$in(@list) ??

use warnings; use strict; my $in = sub { my $x=shift; return scalar grep {$x eq $_} @_ }; if ( 5 ->$in (0..9) ) { print "bin ich drin oder was?"; } if ( 'x' ->$in (0..9) ) { print "mennoooooo... :("; }

/usr/bin/perl -w /tmp/in.pl bin ich drin oder was? Compilation finished at Wed Aug 26 15:42:03
(diabolic laughter)

Cheers Rolf
(addicted to the Perl Programming Language and ☆☆☆☆ :)
Je suis Charlie!

Replies are listed 'Best First'.
Re^3: Create a new operator, get LHS (lexical method)
by shmem (Chancellor) on Aug 26, 2015 at 17:36 UTC
    (diabolic laughter)

    /me concurs. Didn't know that was even possible. Thanks, LanX. Learned something new today.

    perl -le'print map{pack c,($-++?1:13)+ord}split//,ESEL'
      Sadly this approach has a serious flaw (apart from the ugly syntax) ... lexical variables are not easily exported.

      :(

      Cheers Rolf
      (addicted to the Perl Programming Language and ☆☆☆☆ :)
      Je suis Charlie!