use strict; while () { print ">", trim($_), "<\n"; } sub trim { my ($text) = @_; $text =~ s/^\s+|\s+$//g; #remove leading/trailing whitespace return $text; } __DATA__ Cowboy Bebop Bubblegum Crisis Big O Dragonball Z