Re: pattern matching

new topic     » topic index » view thread      » older message » newer message

Hi David!

Here is an example of using the carot see if the comparison begins with a
string:

.
.
.
$comparison1="Name: Janet";  #contains the string to scan for a match
$comparison2="NamQ: Janet";  #contains the string to scan for a match

print "<br>";
if ($comparison1 =~/^Nam/) {print "Hey it starts with the string!;"}

print "<br>";
if ($comparison2 =~/^Name/){print "Hey, this one too!";}
 else {print "gosh, this one doesn't";}

quit;

The above yields:


Hey it starts with the string!;
gosh, this one doesn't

Cheers!

--Warren

new topic     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu