#!/usr/bin/perl

#RE! finally...
#re1.pl

print " re examples....\n";
$name = "shlomo hershkop";
$parts = "lom";
#if($name =~ /lom/){
#or, you can use variable here... 
if($name =~ /$parts/){
	print " found match with $parts in \" $name \" \n";
}
else{
	print "no match found\n";
}

#this is re2.pl
$s = "hello world";
print '$s=[', $s, "]\n";
#that 'm' in m// is optional. it means 'match'....
if($s =~ m/x/) 
	{ print "there\'s an x in ",$s,"\n" }
else 
	{ print "there isn\'t x in $s \n" }

$s = "heLLo world";
if ($s =~ m/L/i) 
	{ print "there is l or L in $s \n" }
else 
	{ print "there isn\'t l or L in $s \n" }

#output:
# $s=[hello world]
# there isn't x
# there a l or L in hello world

$s = "hello world";
print '$s=[',$s,"]\n";
$t = ($s =~ s/l/x/g);  #return the number of matched letters.
print '$t=[', $t, "]\n";
print '$s=[', $s, "]\n";

# this outputs:
# $s=[hello world]
# $t=[3] 
# $s=[hexxo worxd]
