open(LS, 'ls|') or die "Cannot open 'ls' for reading\n"; while () { chomp; #Added after some thought. print "$_\n"; } close LS;