use strict; my @lines = ; chomp @lines; foreach (@lines) { my @words = split " ", $_; print "\$_: '$_'\n"; foreach (@words) { print "'$_' "; } print "\n\n"; } __DATA__ Delimit each word with one or more spaces This is the second line #### $_: ' Delimit each word with one or more spaces' 'Delimit' 'each' 'word' 'with' 'one' 'or' 'more' 'spaces' $_: ' This is the second line' 'This' 'is' 'the' 'second' 'line' #### my @words = split;