#!/usr/bin/perl use strict; use warnings; my @lines = ; # Don't do this unless necessary. :) chomp( @lines ); # Removes IRSs from all lines. # Loops through array, pulls out a line, trims white space from front # and back and prints the line. foreach my $line ( @lines ) { $line = trimSpaces( $line ); print $line, "\n"; } # The regular expression in the subroutine looks for zero # or more space characters at the beginning and end of the # line and removes them. sub trimSpaces() { my $value = shift( @_ ); $value =~ s/(^\s*|\s*$)//g; return $value; } __DATA__ hi there this and that and the other thing blah blah blah one two there four five six