topical media & game development

talk show tell print

basic-regex-26-CharacterClass.pl / pl



  #!/usr/bin/perl -w
  use strict;
  print "Enter a character class to be used as a pattern: ";
  my myPattern = <STDIN>;
  print "\n\nEnter a string to test against the character class: ";
  my myTestString = <STDIN>;
  chomp (myPattern);
  chomp (myTestString);
  print "\n\nThe string you entered was: 'myTestString'.\n";
  print "The pattern you entered was: 'myPattern'.\n";
  if (myTestString =~ m/myPattern/)
  {
   print "There was a match: '&'.\n";
  }
  else
  {
   print "There was no match.";
  }


(C) Æliens 20/2/2008

You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.