in reply to Re^2: Reading from files
in thread Reading from files

The matching only happens once, unless you specify the /g modifier.

I'd probably use look-arounds for what you need:

#!/usr/bin/perl use warnings; use strict; use Syntax::Construct qw{ \K }; while (<DATA>) { s/ (?:clothes|something) # Starting keyword. \K # Don't include the previous part into th +e replacement. (.*?) # The part to be quoted. (?=\.m) # Followed by ".m". /'$1'/xg; print; } __DATA__ abc clothes doing shopping at the .m abc something doing shopping at t +he .mabc
($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,