Beefy Boxes and Bandwidth Generously Provided by pair Networks Joe
P is for Practical
 
PerlMonks  

Re: using callback function

by antirice (Priest)
on Aug 24, 2004 at 00:06 UTC ( [id://385310]=note: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.


in reply to using callback function

A few things:

  1. Check out perldoc perlsub for information about using prototypes and what &j() actually does.
  2. sub j ($i,$j,$k) { should be replaced with sub j { ($i,$j,$k) = @_;
  3. To get a reference to a sub, use \&h.

Put it all together and you get:

sub h { my ($x,$y)=@_; print "the val of x is $#$x and y is $#$y\n"; } sub j { my ($i, $j, $k) = @_; print "\ni am in the function j\n\n"; &$k($i,$j); # or $k->($i,$j); } my @ar = qw/1 2 3 4/; my @vr = qw/56 7 8 9/; j(\@ar, \@vr, \&h); __END__

antirice    
The first rule of Perl club is - use Perl
The
ith rule of Perl club is - follow rule i - 1 for i > 1

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://385310]
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.