SPUG: Removing newlines from a multi-line string - questions
Joshua Lanza
joshlanza at hotmail.com
Wed Mar 14 14:13:25 CST 2001
It was the "\r". Thank you all 10,000 times. SPUG rules! Windows does not
rule!
>From: Dan Ebert <dan at enic.cc>
>CC: "'spug-list at pm.org'" <spug-list at pm.org>
>Subject: Re: SPUG: Removing newlines from a multi-line string - questions
>Date: Wed, 14 Mar 2001 11:50:04 -0800
>
>
>I am fairly sure that perl treats the \n and \r as distinct entities
>when a script is run on a UNIX platform. So you would need the
>s/[\n\r]//g to make sure you're getting rid of what you want. I don't
>know if perl handles \n & \r differently on a Windows platform.
>
>
>-----------------------------------------------------------
>Dan Ebert dan at enic.cc eNIC Corporation
>
>"I haven't lost my mind; I know exactly where I left it."
>-----------------------------------------------------------
>
>Lorraine Johnson wrote:
> >
> > Enlightenment search:
> >
> > 1. Joshua writes:
> > "The problem is that it puts newline characters in the HTML at the end
>of
> > every line in the HTML blob"
> > Um, doesn't the phrase "at the end of every line" imply that the HTML
>blob
> > already HAS newlines (end-of-line markers), and that Perl is PRESERVING
> > rather than ADDING newlines?
> >
> > 2. David writes
> > "on Windows, you are dealing with two characters at the end of each
>line"
> > My understanding is that Perl knows what and how many characters
>actually
> > comprise a newline (EOL) and handles them transparently. For example,
>on
> > Windows, \n is equivalent to CR plus LF. Doesn't a requirement to
>handle
> > text processing differently depending on platform go against the idea of
> > Perl portability?
> >
> > Thanks,
> >
> > Lorraine
> >
> > -----Original Message-----
> > From: David Vergin [mailto:dvergin at igc.org]
> > Sent: Wednesday, March 14, 2001 1:41 AM
> > To: Joshua Lanza; spug-list at pm.org
> > Subject: RE: SPUG: Removing newlines from a multi-line string
> >
> > If you are on Windows, you are dealing with two characters at the end of
> > each
> > line: \r and \n.
> > (And you don't need /i (case-insensitive matches)). So try:
> >
> > $html =~ s/[\n\r]//g;
> >
> > dv
> >
> > > -----Original Message-----
> > > From: owner-spug-list at pm.org [mailto:owner-spug-list at pm.org]On Behalf
>Of
> > > Joshua Lanza
> > > Sent: Wednesday, March 14, 2001 12:01 AM
> > > To: spug-list at pm.org
> > > Subject: SPUG: Removing newlines from a multi-line string
> > >
> > >
> > > Hi all,
> > >
> > > I have a script that gets a chunk of HTML from an access database and
> > plunks
> > > it into a template. The problem is that it puts newline characters in
>the
> > > HTML at the end of every line in the HTML blob, which is (1) unseemly
>and
> > > (2) making it difficult to manipulate the text after the pages are
> > > generated.
> > >
> > > I store the text in $html and then try
> > >
> > > $html =~ s/\n//ig;
> > >
> > > but nothing seems to happen. If this worked it would solve (2) from
>above
> > > but wouldn't help (1). I guess what I'm really looking for is why I'm
> > > getting the extra newlines in the first place. Any thoughts greatly
> > > appreciated,
> > >
> > > Josh
> > >
>
>--
>
> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
> POST TO: spug-list at pm.org PROBLEMS: owner-spug-list at pm.org
> Subscriptions; Email to majordomo at pm.org: ACTION LIST EMAIL
> Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address
> For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest
> Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/
>
>
_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
POST TO: spug-list at pm.org PROBLEMS: owner-spug-list at pm.org
Subscriptions; Email to majordomo at pm.org: ACTION LIST EMAIL
Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address
For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest
Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/
More information about the spug-list
mailing list