in reply to formatting text
Using your own global substitution s!\s+! !g, but shortening everything else:
while (<DATA>) { next if !/^<item>/; s!\s+! !g; print "$_\n"; } __DATA__ <item>sample item text one <item>sample item text two <item>sample item text three <item>sample item text four
|
|---|