$orgtext = Whey; # this one right here $newtext = Popcorn; #### $orgtext = /[Ww]hey/; # this one right here $newtext = Popcorn; #### $orgtext = ( $_ =~ /[Ww]hey/ ); #### $orgtext = qr/[Wwhey]/; #### $orgtext = //; # this one right here $newtext = block; #### $orgtext = qr//sg; # s is needed so that "." matches newline #### $intext =~ s/$orgtext/$newtext/ms; # the ms is for coping correctly with newlines (that can easily appear in a binary). ... # replaces ALL occurrences of orgtext with newtext and places the number of occurences in $count