use warnings; use strict; my $x = "aiutino aiutino argh! aiutino"; warn "Argh, one time" for $x =~ / \b aiutino \b /ix; warn "Argh, three times" for $x =~ / \b aiutino \b /gix;