cat test.dat | perl -n -e 'chomp; s/^\s+//; s/\s+$//; print "$_\n";'