while () { next if !/^/; s!\s+! !g; print "$_\n"; } __DATA__ sample item text one sample item text two sample item text three sample item text four