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
In reply to Re: Subroutines with Parameters
by davido
in thread Subroutines with Parameters
by MoniqueLT
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |