Gossamer Forum
Home : General : Perl Programming :

Passing pattern to subroutine

Quote Reply
Passing pattern to subroutine
Not following why this matches everything, or
if it's the best way, can someone advise?:

@array1=('Bill', 'Betty', 'Fred', 'Freda')

sub MatchIt($stringtest){
foreach(@array1){
if($_ =~ $stringtest){
print "Match: $_\n";
}
}
}

&MatchIt(/re/);
Subject Author Views Date
Thread Passing pattern to subroutine Masque 3951 Oct 26, 1998, 11:17 AM
Post Re: Passing pattern to subroutine
Alex 3830 Oct 26, 1998, 2:23 PM
Post Re: Passing pattern to subroutine
Masque 3827 Oct 27, 1998, 1:01 AM