Joseph Paish wrote: > > i have a data file that i am reading into an array. some of the data file > entries have a space at the end of the line and some do not. is there some > way that i can delete the space if it exists as i read each line (something > like chomp deletes newlines if they exist)? preferably something legible to > a perl newbie (i am going to have to maintain this in the future, and the > less obscure the code, the better). > > thanks > > joe > > ps. examples of data file entries : > > first line of file > second line of file > third line of file > > the space at the end of the second line is invisible just to look at it, but > i need to strip it off as i read it.
If the current line is in $_ (the default): s/\s+$//; If instead you have assigned the current line to a variable like $line $line =~ s/\s+$//; P.S. This is a Frequently Asked Question and is answered in the perlfaq4 document that is supplied with Perl. perldoc -q "How do I strip blank space from the beginning/end of a string" John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]