From walter at frii.com Tue Oct 15 14:46:31 2002 From: walter at frii.com (Walter Pienciak) Date: Mon Aug 2 21:25:47 2004 Subject: [Boulder-pm] Re: Perl Quiz of the Week Message-ID: >I taught a class in Illinois last week, and one of the students asked >if there was a mailing list that would deliver a weekly Perl quiz or >programming puzzle. I said I didn't know of one, but that it sounded >like a good idea, and that I would set one up when I got back. > >I am now back. If you want to get the quiz-of-the-week, send a note >to > > perl-qotw-subscribe@plover.com > > >Please feel free to circulate this announcement to appropriate venues. > >Thanks. From walter at frii.com Fri Oct 18 12:09:35 2002 From: walter at frii.com (Walter Pienciak) Date: Mon Aug 2 21:25:47 2004 Subject: [Boulder.pm] perl/HTML/XHTML Message-ID: Howdy, and welcome to the almost-weekend. For a web-upload mechanism of mine, I'm adding QC modules that check/delete pesky Control-M's and whack excessive amounts of empty lines. Now, with the file contents in $Content, the first is easy: $Content =~ s/^M//go; But the second, hrmmm. Because if someone is uploading a file with preformatted content, we DON'T want to whack those newlines. So while the simple solution of $Content =~ s/\n+/\n/go; works for 99% of the files on the site, it will destroy the last 1%. And this is a bit too naive: $Content =~ /
/io # Skip it

So, any ideas about a robust solution? Or, for that matter, just
a list of tags that should indicate a hands-off approach?

Walter


From KSmith at netLibrary.com  Fri Oct 18 12:18:43 2002
From: KSmith at netLibrary.com (Keanan Smith)
Date: Mon Aug  2 21:25:47 2004
Subject: [Boulder.pm] perl/HTML/XHTML
Message-ID: <8B499C5ACCA965439B3F6712E7ADABBD5BD09F@mailman.netlibrary.com>

$Content =~ s/\n+(?!(?:(?!...
tags -----Original Message----- From: Walter Pienciak [mailto:walter@frii.com] Sent: Friday, October 18, 2002 11:10 AM To: boulder-pm@mail.pm.org Subject: [Boulder.pm] perl/HTML/XHTML Howdy, and welcome to the almost-weekend. For a web-upload mechanism of mine, I'm adding QC modules that check/delete pesky Control-M's and whack excessive amounts of empty lines. Now, with the file contents in $Content, the first is easy: $Content =~ s/^M//go; But the second, hrmmm. Because if someone is uploading a file with preformatted content, we DON'T want to whack those newlines. So while the simple solution of $Content =~ s/\n+/\n/go; works for 99% of the files on the site, it will destroy the last 1%. And this is a bit too naive: $Content =~ /
/io # Skip it

So, any ideas about a robust solution? Or, for that matter, just
a list of tags that should indicate a hands-off approach?

Walter

_______________________________________________
Boulder-pm mailing list
Boulder-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boulder-pm

From walter at frii.com  Fri Oct 18 12:30:52 2002
From: walter at frii.com (Walter Pienciak)
Date: Mon Aug  2 21:25:47 2004
Subject: [Boulder.pm] perl/HTML/XHTML
In-Reply-To: <8B499C5ACCA965439B3F6712E7ADABBD5BD09F@mailman.netlibrary.com>
Message-ID: 

On Fri, 18 Oct 2002, Keanan Smith wrote:

> $Content =~ s/\n+(?!(?:(?!
> Remove all newlines that aren't in 
...
tags That is a nifty regex. Thanks. Walter From charlesa at pobox.com Fri Oct 18 12:37:21 2002 From: charlesa at pobox.com (Charles Albrecht) Date: Mon Aug 2 21:25:47 2004 Subject: [Boulder.pm] perl/HTML/XHTML In-Reply-To: References: Message-ID: At 11:09 AM -0600 10/18/2002, Walter Pienciak wrote: >Howdy, and welcome to the almost-weekend. > >For a web-upload mechanism of mine, I'm adding QC modules that >check/delete pesky Control-M's and whack excessive amounts of >empty lines. > >Now, with the file contents in $Content, the first is easy: > > $Content =~ s/^M//go; For this step, how about the standard line ending switcher (since ctrl-M - Carriage Return - is \015): $Content =~ s/(\015\012|\012|\015)/\n/go; >But the second, hrmmm. Because if someone is uploading a file >with preformatted content, we DON'T want to whack those newlines. Keenan's regex looks great for this. -Charles Euonymic Solutions charlesa@pobox.com From KSmith at netLibrary.com Fri Oct 18 12:48:42 2002 From: KSmith at netLibrary.com (Keanan Smith) Date: Mon Aug 2 21:25:47 2004 Subject: [Boulder.pm] perl/HTML/XHTML Message-ID: <8B499C5ACCA965439B3F6712E7ADABBD5BD0A0@mailman.netlibrary.com> For that I usually simply do: $Content =~ s/[\r\n]*/\n/go; -----Original Message----- From: Charles Albrecht [mailto:charlesa@pobox.com] Sent: Friday, October 18, 2002 11:37 AM To: boulder-pm@mail.pm.org Subject: Re: [Boulder.pm] perl/HTML/XHTML At 11:09 AM -0600 10/18/2002, Walter Pienciak wrote: >Howdy, and welcome to the almost-weekend. > >For a web-upload mechanism of mine, I'm adding QC modules that >check/delete pesky Control-M's and whack excessive amounts of >empty lines. > >Now, with the file contents in $Content, the first is easy: > > $Content =~ s/^M//go; For this step, how about the standard line ending switcher (since ctrl-M - Carriage Return - is \015): $Content =~ s/(\015\012|\012|\015)/\n/go; >But the second, hrmmm. Because if someone is uploading a file >with preformatted content, we DON'T want to whack those newlines. Keenan's regex looks great for this. -Charles Euonymic Solutions charlesa@pobox.com _______________________________________________ Boulder-pm mailing list Boulder-pm@mail.pm.org http://mail.pm.org/mailman/listinfo/boulder-pm From KSmith at netLibrary.com Fri Oct 18 12:49:16 2002 From: KSmith at netLibrary.com (Keanan Smith) Date: Mon Aug 2 21:25:47 2004 Subject: [Boulder.pm] perl/HTML/XHTML Message-ID: <8B499C5ACCA965439B3F6712E7ADABBD5BD0A1@mailman.netlibrary.com> Err That should have been: s/[\r\n]+/\n/go; -----Original Message----- From: Charles Albrecht [mailto:charlesa@pobox.com] Sent: Friday, October 18, 2002 11:37 AM To: boulder-pm@mail.pm.org Subject: Re: [Boulder.pm] perl/HTML/XHTML At 11:09 AM -0600 10/18/2002, Walter Pienciak wrote: >Howdy, and welcome to the almost-weekend. > >For a web-upload mechanism of mine, I'm adding QC modules that >check/delete pesky Control-M's and whack excessive amounts of >empty lines. > >Now, with the file contents in $Content, the first is easy: > > $Content =~ s/^M//go; For this step, how about the standard line ending switcher (since ctrl-M - Carriage Return - is \015): $Content =~ s/(\015\012|\012|\015)/\n/go; >But the second, hrmmm. Because if someone is uploading a file >with preformatted content, we DON'T want to whack those newlines. Keenan's regex looks great for this. -Charles Euonymic Solutions charlesa@pobox.com _______________________________________________ Boulder-pm mailing list Boulder-pm@mail.pm.org http://mail.pm.org/mailman/listinfo/boulder-pm From charlesa at pobox.com Fri Oct 18 13:00:34 2002 From: charlesa at pobox.com (Charles Albrecht) Date: Mon Aug 2 21:25:47 2004 Subject: [Boulder.pm] perl/HTML/XHTML In-Reply-To: <8B499C5ACCA965439B3F6712E7ADABBD5BD0A1@mailman.netlibrary.com> References: <8B499C5ACCA965439B3F6712E7ADABBD5BD0A1@mailman.netlibrary.com> Message-ID: I go with the octal literals for portability - \r and \n are not equivalent to \015 and \012 on all platforms. -C At 11:49 AM -0600 10/18/2002, Keanan Smith wrote: >Err That should have been: >s/[\r\n]+/\n/go; > >-----Original Message----- >From: Charles Albrecht [mailto:charlesa@pobox.com] >Sent: Friday, October 18, 2002 11:37 AM >To: boulder-pm@mail.pm.org >Subject: Re: [Boulder.pm] perl/HTML/XHTML > > >At 11:09 AM -0600 10/18/2002, Walter Pienciak wrote: >>Howdy, and welcome to the almost-weekend. >> >>For a web-upload mechanism of mine, I'm adding QC modules that >>check/delete pesky Control-M's and whack excessive amounts of >>empty lines. >> >>Now, with the file contents in $Content, the first is easy: >> >> $Content =~ s/^M//go; > >For this step, how about the standard line ending switcher (since ctrl-M - >Carriage Return - is \015): > >$Content =~ s/(\015\012|\012|\015)/\n/go; > >>But the second, hrmmm. Because if someone is uploading a file >>with preformatted content, we DON'T want to whack those newlines. > >Keenan's regex looks great for this. > >-Charles > Euonymic Solutions > charlesa@pobox.com >_______________________________________________ >Boulder-pm mailing list >Boulder-pm@mail.pm.org >http://mail.pm.org/mailman/listinfo/boulder-pm >_______________________________________________ >Boulder-pm mailing list >Boulder-pm@mail.pm.org >http://mail.pm.org/mailman/listinfo/boulder-pm From charlesa at pobox.com Fri Oct 18 13:05:19 2002 From: charlesa at pobox.com (Charles Albrecht) Date: Mon Aug 2 21:25:47 2004 Subject: [Boulder.pm] perl/HTML/XHTML In-Reply-To: References: <8B499C5ACCA965439B3F6712E7ADABBD5BD0A1@mailman.netlibrary.com> Message-ID: And because I generally want to retain all the line endings in the original. At 12:00 PM -0600 10/18/2002, Charles Albrecht wrote: >I go with the octal literals for portability - \r and \n are not equivalent to \015 and \012 on all platforms. > >-C > >At 11:49 AM -0600 10/18/2002, Keanan Smith wrote: >>Err That should have been: >>s/[\r\n]+/\n/go; >> >>-----Original Message----- >>From: Charles Albrecht [mailto:charlesa@pobox.com] >>Sent: Friday, October 18, 2002 11:37 AM >>To: boulder-pm@mail.pm.org >>Subject: Re: [Boulder.pm] perl/HTML/XHTML >> >>$Content =~ s/(\015\012|\012|\015)/\n/go; From KSmith at netLibrary.com Fri Oct 18 13:56:57 2002 From: KSmith at netLibrary.com (Keanan Smith) Date: Mon Aug 2 21:25:47 2004 Subject: [Boulder.pm] perl/HTML/XHTML Message-ID: <8B499C5ACCA965439B3F6712E7ADABBD5BD0A3@mailman.netlibrary.com> I suppose it depends on your implementation and requirements ;) -----Original Message----- From: Charles Albrecht [mailto:charlesa@pobox.com] Sent: Friday, October 18, 2002 12:05 PM To: boulder-pm@mail.pm.org Subject: RE: [Boulder.pm] perl/HTML/XHTML And because I generally want to retain all the line endings in the original. At 12:00 PM -0600 10/18/2002, Charles Albrecht wrote: >I go with the octal literals for portability - \r and \n are not equivalent to \015 and \012 on all platforms. > >-C > >At 11:49 AM -0600 10/18/2002, Keanan Smith wrote: >>Err That should have been: >>s/[\r\n]+/\n/go; >> >>-----Original Message----- >>From: Charles Albrecht [mailto:charlesa@pobox.com] >>Sent: Friday, October 18, 2002 11:37 AM >>To: boulder-pm@mail.pm.org >>Subject: Re: [Boulder.pm] perl/HTML/XHTML >> >>$Content =~ s/(\015\012|\012|\015)/\n/go; _______________________________________________ Boulder-pm mailing list Boulder-pm@mail.pm.org http://mail.pm.org/mailman/listinfo/boulder-pm