Passing Variables and Functions

Regular variables and functions are quite easy to pass: just pass in a reference to an existing or anonymous variable or function:

    func( \$some_scalar );
    func( \@some_array  );
    func( [ 1 .. 10 ]   );
    func( \%some_hash   );
    func( { this => 10, that => 20 }   );
    func( \&some_func   );
    func( sub { $_[0] ** $_[1] }   );


Back to perlfaq7