Joe -

Take heart - learn regexs! Soon their crypticism
will turn to elegant beauty, and you will be a
much more powerful perl scripter.

Aloha => Beau.

-----Original Message-----
From: Joseph Paish [mailto:[EMAIL PROTECTED]]
Sent: Sunday, December 01, 2002 3:36 AM
To: perl_beginner
Subject: Re: how to delete space at end of line


On Friday 29 November 2002 14:28, you wrote:
> 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

thanks to all that replied.

i guess i have to learn my way around regular expressions now.  i've managed
to go this long without studying them because i find them to be cryptic (to
say the least).  at least this one is fairly simple, and by deconstructing
it
piece by piece, i can even understand how it works.

joe

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to