#!/usr/bin/perl -w
use strict;

#delcare variables 
my @test = ("3.14159","3214159","3=14159");
my @test2 = ("fre","fred","fredd","freddd");

my $test3 = "3214159fred";

#test . and \.
print "\nI am testing . and \. here:\n";
foreach my $val(@test)
{
    if($val =~/3.14159/)
    {
	print "\n$val matches to '/3.14159/'\n";
    }
    if($val =~/3\.14159/)
    {
	print "\n$val matches to '/3\.14159/'\n";
    }
}

#test + and *
print "\nI am testing +, * and {N,M} here:\n";
foreach my $val(@test2)
{
    if($val =~/fred*/)
    {
	print "\n$val matches to '/fred*/'\n";
    }
    if($val =~/fred+/)
    {
	print "\n$val matches to '/fred+/'\n";
    }
    #at least 2 times
    if($val =~/fred{2,}/)
    {
	print "\n$val matches to '/fred{2,}'\n";
    }
}


#test []
print "\nI am testing [] and grouping here\n";
if($test3 =~/([0-9]+)([a-z]+)/)
{
    #why can I use $1 here without declare it?
    print "\nThere is a match and thenumber part is:$1 and the letter part is:$2\n";
}



print "\nI am testing | here\n";

my $newtest1 = "1abc";
my $newtest2 = "2abc";

if(($newtest1 =~/(1|2)abc/)and($newtest2 =~/(1|2)abc/))
{
    print "\nBoth $newtest1 and $newtest2 matches to '/(1|2)abc/'\n";
}


#test ^ &
my $hellobye = "Hello, Bye";
my $byehello = "Bye,Hello";

if(($hellobye =~/Hello/) and ($byehello =~/Hello/))
{
    print "\nBoth $hellobye and $byehello match to '/Hello/'\n";
}
if($hellobye =~/^Hello/)
{
    print "\n$hellobye matches to '/^Hello/'\n";
}
else
{
    print "\n$hellobye doesn't matches to '/^Hello/'\n";
}
if($byehello=~/^Hello/)
{
    print "\n$byehello matches to '/^Hello/'\n";
}
else
{
    print "\n$byehello doesn't matches to '/^Hello/'\n";
}

if(($hellobye =~/Bye/) and ($byehello =~/Bye/))
{
    print "\nBoth $hellobye and $byehello match to '/Bye/'\n";
}
if($hellobye =~/Bye$/)
{
    print "\n$hellobye matches to /Bye\$/\n";
}
else
{
    print "\n$hellobye doesn't matches to /Bye\$/\n";
}
if($byehello=~/Bye$/)
{
    print "\n$byehello matches to /Bye\$/ \n";
}
else
{
    print "\n$byehello doesn't matches to /Bye\$/ \n";
}



