foreach $line (@array) { $line =~ s/\s{1}//g; } #### #!/usr/local/bin/perl -w use strict; open (FH, $ARGV[0]) or die "unable to open input file: $!"; # more helpful message open (OUTFILE, ">$ARGV[1]") or die "unable to open output file: $!"; # this should have one too while (){ chomp; my @array = split; print OUTFILE "@array\n"; # or whatever has to be done } #### #!/usr/local/bin/perl -w use strict; while (<>){ chomp; my @array = split; print "@array\n"; # or whatever has to be done }