in reply to Cannot get Perl to match a specific string in my textfile

The comma doesn't do what you think. Replace it with || and it matches that line. SSCCE:

#!/usr/bin/perl use strict; use warnings; use autodie; my %replacements = ( 'user.name@domain.com' => 'uname', 'user@domain.com' => 'user', ); $_ = ' "user@domain.com:Calendar/BCA-513DD600-1B-6967B200"'; #if (m/:Calendar(?=\/)/, m/:Contacts(?=\/)/, m/(?<=\"\/)Users/, m/.+@. ++\"\s=/) { if (m/:Calendar(?=\/)/ || m/:Contacts(?=\/)/ || m/(?<=\"\/)Users/ || m +/.+@.+\"\s=/) { print "Matched\n"; # then replace every occurrence as in list foreach my $key (sort keys %replacements) { s/\b$key\b/$replacements{$key}/g; } } print "$_\n";