in reply to Subroutines with Parameters

perlsub. Even perlintro! (Spend 20 minutes reading perldoc perlintro before your next question.)

One thing to note: Probably the best way to pass a regular expression to your subroutine is to pass a regexp object, obtained using the qr// operator described in perlop. Example:

sub test_match { my( $regexp, $string ) = @_; return scalar( $string =~ $regexp ); } my $string = "Hello world!\n"; print $string if test_match( qr/hello/i, $string );

Dave

Replies are listed 'Best First'.
Re^2: Subroutines with Parameters
by Anonymous Monk on Nov 04, 2013 at 03:32 UTC