topical media & game development

talk show tell print

basic-regex-26-SimpleReplace.pl / pl



  #!/usr/bin/perl -w
  use strict;
  my myString = "I attended a Star Training Company training course.";
  my oldString = myString;
  myString =~ s/Star/Moon/;
  print "The original string was: \n'oldString'\n\n";
  print "After replacement the string is: \n'myString'\n\n";
  if (oldString =~ m/Star/)
  {
  print "The string 'Star' was matched and replaced in the old string";
  }


(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.