in reply to Method for reducing tedium of transferring object properties to scalars

You are asking several different questions in the same time: I'm confused. .. my best guess is that you want something like a with(object){ } statement like in JS...

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

  • Comment on Re: Method for reducing tedium of transferring object properties to scalars
  • Download Code

Replies are listed 'Best First'.
Re^2: Method for reducing tedium of transferring object properties to scalars
by shmem (Chancellor) on Apr 22, 2017 at 09:50 UTC
    my best guess is that you want something like a with(object){ } statement like in JS...

    Oh! great oppotunity for being silly...

    package Foo { sub new { bless { foo => 'bar', baz => 'quux', }; } sub get_foo { $_[0]->{foo}; } sub get_baz { $_[0]->{baz}; } } sub with (&$@) { my $code = shift; my $obj = shift; map { my $meth = $_; local $_ = $obj->$meth; $code->(); } @_; } my $obj = Foo->new; my @methods = qw(get_foo get_baz); with { print "val: $_\n"; } $obj, @methods;

    ;-)

    perl -le'print map{pack c,($-++?1:13)+ord}split//,ESEL'
      Roughly almost ... no ... almost roughly ...

      ;)

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