Arman Akbarian
UNIVERSITY OF BRITISH COLUMBIA
PHYSICS & ASTRONOMY DEPT.

#!/usr/bin/perl -w
#--------------------------------------------------
# AAK: This documents explains regular expressions
# in perl, though I am not sure how clear the whole 
# thing might be!
# Last update:
# Tue Sep 11 22:19:36 PDT 2012
# --------------------------------------------------
#Convention: 
# [] means optional pattern match
# <> means necessary pattern match
# WS = tab or space
# AWS = tab space or endofline character
#----------------------------------------

#use 5.010;

#-------------------------------
#Checks to see if string has pattern: 
#  [WS]<realnumber>[WS]
#-------------------------------
sub real_num_match {
   my $string;
   $string = $_[0];
   if ( $string =~ /^([\t ]*)(-\d+)?(\d*\.?\d+)?(e-?\d+)?[\t ]*$/i )
        { return 1; }
   else { return -1; }

}

#-------------------------------------------
#Checks to see if string has pattern:
# [AWS] <string [AWS] = [AWS] string> [AWS]
# This is useful for reading parameter file
#-------------------------------------------

sub str_eq_match {
   my $string;
   $string = $_[0];
   if ( $string =~ /(\s*\b\w\b\s*=\s*\b\w\b\s*)/ )
      {return 1; }
   else    {return -1; }
}

#----------------------
# Matches to pattern:
# [sth] {sth} 
# ---------------------
sub link_match {
   my $string;
   $string = $_[0];
   if ( $string =~ /\[(.+)\]\s*\{(.*)\}/ )
   { }
   else
   { return -1;}
}
$tmp='';

while ( <> ) {
$tmp = $tmp . $_;
}

$res=&str_eq_match($tmp);
print "Result of Test is: $res\n";


last update: Wed May 11, 2016