while () { ($first) = $_ =~ m/^(\S+)/; print "$first\n"; } __DATA__ This is a line. Another line is here. Here's a line. Line five is this one. #### while () { $first = (split/\s/)[0]; print "$first\n"; } #### while () { $first = substr $_, 0, index $_, " "; print "$first\n"; }