in reply to calling methods using array variables

But, i think you did not get my problem here.

actual function call is like this,
@jobIds = $jobs->get_jobIds($ARGV[0]);
which is actually a object reference, from which calling a function with arguments passed.

I have this function name and arguments in an array now. so the function what i need would be like this, if right.

@jobIds = $jobs->$args_input[2]($args_input[3]);
But this is not right. How would I achieve this for a object reference.

Thanks
rsennat

Replies are listed 'Best First'.
Re^2: calling functions using array variables
by davorg (Chancellor) on Nov 28, 2005 at 10:44 UTC

    Oh. Ok, so your problem is in calling a method.

    Then the solution is get the name of the method into a scalar variable before trying to call it.

    #!/usr/bin/perl use strict; use warnings; package Foo; sub new { bless {}, shift; } sub test { print "pass\n"; } package main; my @subs = ('test'); my $foo = Foo->new; my $method = $subs[0]; $foo->$method;
    --
    <http://dave.org.uk>

    "The first rule of Perl club is you do not talk about Perl club."
    -- Chip Salzenberg

      my $method = $subs[0]; $foo->$method;

      Or, if you're in the mood for obfuscation:

      $foo->${ \$subs[0] };
      Thats really gr8 stuff!!!!!!!!!!!!!!

      For calling methods from array variables. cool.

      Thanks a lot.

      rsennat