Mega Code Archive

 
Categories / Perl / Regular Expression
 

Occurences of planet were changed to world

use strict; use warnings; my $string = "This planet is our planet."; print "$string\n"; my $matches = $string =~ s/planet/world/g; print "$matches occurences of planet were changed to world.\n"; print "The new string is: $string\n";