[24716] in Perl-Users-Digest
Perl-Users Digest, Issue: 6871 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Aug 16 18:06:09 2004
Date: Mon, 16 Aug 2004 15:05:10 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Mon, 16 Aug 2004 Volume: 10 Number: 6871
Today's topics:
an approach (db2guy)
Re: an approach ctcgag@hotmail.com
Re: Counting text area <noreply@gunnar.cc>
Documentation for PDF::API2 <shawn.corey@sympatico.ca>
Re: Earthquake forecasting program Aug. 16, 2004 <jaxtraw@nospamnobigfoot.com>
Re: Extract same text from file. <Joe.Smith@inwap.com>
Re: File::Find in FreeBSD msdosfs mounts <Joe.Smith@inwap.com>
Re: Good way to un-chomp an array <jurgenex@hotmail.com>
Re: Good way to un-chomp an array <tadmc@augustmail.com>
Re: Good way to un-chomp an array (Randal L. Schwartz)
Re: has anybody write bioinformatics programme with per (Bill)
How do I pick up existing objects in event handling cod <Graham.T.removethis.Wood@oracle.andthis.com>
Is GD library independent? <SaveWorldFromAids@alexa.com>
Re: Is GD library independent? <geenbestaandadres@lycos.nl>
Re: Is GD library independent? <gnari@simnet.is>
Re: LWP & Javascript <spam@infocopter.ch>
Materializing an indirect sort using only swap ctcgag@hotmail.com
One liner for renaming files (D. Alvarado)
Parsing a text file into an array (Scott)
Re: Parsing a text file into an array <mritty@gmail.com>
Re: Problems with proxy .. <jgibson@mail.arc.nasa.gov>
Re: Regexp: substituting \n with <br /> except in certa <noreply@gunnar.cc>
Re: Regexp: substituting \n with <br /> except in certa <gnari@simnet.is>
Re: Regexp: substituting \n with <br /> except in certa <noreply@gunnar.cc>
Re: Regexp: substituting \n with <br /> except in certa <gnari@simnet.is>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 16 Aug 2004 12:03:53 -0700
From: db2boom@yahoo.com (db2guy)
Subject: an approach
Message-Id: <ca559432.0408161103.24304688@posting.google.com>
i am working on db2 and need a perl script to delete data from a
table. There is a column in that table X lets say Xdate. Now i want to
keep only 90 days of data and delete everything else. The Xdate is in
timestamp format so its creating problems for me. ex
2004-03-31-00.00.00 so when i do current timestamp - 90 days the
problem is coming with time part of timestamp.
Can anyone suggest me a way.
Also how can i put this values
db2 "select count(*) from tableX" into a variable say $DD...
any suggestion will be appriciated thanks...
------------------------------
Date: 16 Aug 2004 19:53:21 GMT
From: ctcgag@hotmail.com
Subject: Re: an approach
Message-Id: <20040816155321.920$VE@newsreader.com>
db2boom@yahoo.com (db2guy) wrote:
> i am working on db2 and need a perl script to delete data from a
> table. There is a column in that table X lets say Xdate. Now i want to
> keep only 90 days of data and delete everything else. The Xdate is in
> timestamp format so its creating problems for me. ex
> 2004-03-31-00.00.00 so when i do current timestamp - 90 days the
> problem is coming with time part of timestamp.
> Can anyone suggest me a way.
> Also how can i put this values
> db2 "select count(*) from tableX" into a variable say $DD...
> any suggestion will be appriciated thanks...
While it may possible to solve this problem with Perl, the proper way
to solve it is almost surely within DB2 itself.
Xho
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
------------------------------
Date: Mon, 16 Aug 2004 18:19:06 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Counting text area
Message-Id: <2oc5hrF8nnm5U1@uni-berlin.de>
John S wrote:
> Gunnar Hjalmarsson wrote:
>> John S wrote:
>>> textarea comes back with \r as well.
>>
>> Only on Windows (of course), and not if you use a library that
>> takes care of it, such as CGI.pm (as Tore suggested) or
>> cgi-lib.pl. Otherwise you can binmode STDOUT to prevent the \r
>> pecularity.
>
> When this is run from an Apache server:
<snip>
> my $fe = $q->param( 'friend_email' ); # text area
>
> my $msg;
> if ( $fe =~ /\r/ ){
> $msg = 'found \r'
> }
<snip>
> print $q -> p( $msg );
<snip>
> I get 'found \r'.
Okay. But don't you mean when a textarea field with linebreaks is
submitted from a Windows browser?
The problem I was talking about (which is related) is that if you
display a textarea field with embedded text in a Windows browser, and
the text includes \r\n linebreaks (which it typically does if the
script is run on Windows), each occurrence of \r *or* \n appears to be
exchanged for \r\n before display. In other words, if you don't
binmode STDOUT, the numbers of linebreaks are doubled.
This sub-thread seems to have turned off topic.
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Mon, 16 Aug 2004 10:48:01 -0400
From: Shawn Corey <shawn.corey@sympatico.ca>
Subject: Documentation for PDF::API2
Message-Id: <aN3Uc.5487$Tr.375881@news20.bellglobal.com>
Hi,
Does anyone know good on-line documentation for PDF::API2? I checked out
http://cpan.uwinnipeg.ca/htdocs/PDF-API2/ but it's just the same old
pathetic PODs that tell you nothing about how to use it. Is there
anything better?
I want to generate PDFs with text that changes. So I need to determine
the width of the text so that it won't go outside my margins; the
equivalent of Font::AFM. But apparently Adobe does not publishes its AFM
files any more.
Thanks.
------------------------------
Date: Mon, 16 Aug 2004 20:29:21 +0100
From: "Jaxtraw" <jaxtraw@nospamnobigfoot.com>
Subject: Re: Earthquake forecasting program Aug. 16, 2004
Message-Id: <1092684544.19111.0@ersa.uk.clara.net>
"edgrsprj" <edgrsprj@ix.netcom.com> wrote in message
news:0f1Uc.23551$nx2.17009@newsread2.news.atl.earthlink.net...
> August 16, 2004 Posted to sci.geo.earthquakes and other Newsgroups
>
> Newsgroup Readers: I recommend that you send copies of this report to any
> government officials and researchers that you know who are interested in
> earthquake forecasting science.
>
> The information in this report represents expressions of personal opinion.
>
> This is an introductory report regarding a Perl language earthquake
> forecasting computer program which is now generating good results. I
> personally believe that the program has the potential to enable us to
> accurately forecast the approach of a reasonable percentage of the
> destructive earthquakes which are occurring around the world. This report
> will explain how the program works.
>
<snip>
Intriguing, but it seems to me you should test also for false negatives.
Checking what signals were received before an earthquake is one side of the
coin, but then basically you're being selective about your data. It would
seem to me to validate the predictive powers of the program, you'd need to
run many tests where an area and date are selected where no earthquake
occurred, to see if the data prior to this "non earthquake" could have been
interpreted as indicating that one would occur. Additionally, you should
also trawl the data for predictions of earthquakes where none occurred.
Ian
------------------------------
Date: Mon, 16 Aug 2004 20:01:22 GMT
From: Joe Smith <Joe.Smith@inwap.com>
Subject: Re: Extract same text from file.
Message-Id: <mo8Uc.135779$8_6.6463@attbi_s04>
Ryan Keeling wrote:
> Such as a file containing all entries for
> MS102_PCP.Implementation and another file for MS102_PCP.Support.
Here's some help regarding multiple output files:
my %filehandles
while(<>){
($dept,$proj) = (...); # Something to pick out the right columns
unless (exists $filehandles{$proj}) {
open $filehandles{$proj}, '>>', "$dept.$proj" or warn
"Cannot append to $dept.$proj: $!\n";
}
print $filehandles{$proj} $_ or warn "Output error $proj: $!\n"
}
As for the part marked (...); that is an exercise for the reader.
-Joe
------------------------------
Date: Mon, 16 Aug 2004 20:19:33 GMT
From: Joe Smith <Joe.Smith@inwap.com>
Subject: Re: File::Find in FreeBSD msdosfs mounts
Message-Id: <pF8Uc.168045$eM2.12279@attbi_s51>
Senandung Mendonan wrote:
> Dear group,
>
> I wrote this perl snippet below on FreeBSD-5.2.1, which I find works
> in normal UFS -type filesystems, but doesn't work in msdosfs mounts
> (File::Find's find() doesn't traverse into directories). The -f test
> inside wanted() also fails. Is this just me, or is this an issue with
> FreeBSD?
What happens if you set File::Find::dont_use_nlink?
Version 1.06 of File::Find (dated January 2004) has this warning:
=head1 CAVEAT
=over 2
=item $dont_use_nlink
You can set the variable C<$File::Find::dont_use_nlink> to 1, if you want to
force File::Find to always stat directories. This was used for file systems
that do not have an C<nlink> count matching the number of sub-directories.
Examples are ISO-9660 (CD-ROM), AFS, HPFS (OS/2 file system), FAT (DOS file
system) and a couple of others.
You shouldn't need to set this variable, since File::Find should now detect
such file systems on-the-fly and switch itself to using stat. This works even
for parts of your file system, like a mounted CD-ROM.
If you do set C<$File::Find::dont_use_nlink> to 1, you will notice slow-downs.
------------------------------
Date: Mon, 16 Aug 2004 13:21:25 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Good way to un-chomp an array
Message-Id: <px2Uc.6995$Kf4.6450@nwrddc02.gnilink.net>
Abhinav wrote:
> Jürgen Exner wrote:
>> for (@array) {
>> process_element;
>> }
>>
>
> Disgressing from the topic, could anyone please explain how (if at
> all) this is different from
>
> foreach (@array) {
> process_element;
> }
It is four keystrokes shorter
> And when to use this instead of the former ?
When you want to save 4 keystrokes.
For further details please see "perldoc perlsyn"
jue
------------------------------
Date: Mon, 16 Aug 2004 07:36:20 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Good way to un-chomp an array
Message-Id: <slrnci1ai4.9n3.tadmc@magna.augustmail.com>
Abhinav <matrix_calling@yahoo.dot.com> wrote:
> Jürgen Exner wrote:
>> for (@array) {
>> process_element;
>> }
>>
>
> Disgressing from the topic, could anyone please explain how (if at all)
The docs for foreach might explain foreach better than some
random person on Usenet...
See the "Foreach Loops" section in perlsyn.pod
The C<foreach> keyword is actually a synonym for the C<for> keyword, so
you can use C<foreach> for readability or C<for> for brevity.
> this is different from
>
> foreach (@array) {
> process_element;
> }
They are not different.
> And when to use this instead of the former ?
Whenever you are not playing Perl Golf. :-)
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 16 Aug 2004 08:26:05 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: Good way to un-chomp an array
Message-Id: <86ekm7yuia.fsf@blue.stonehenge.com>
>>>>> "Eugene" == Eugene Mikheyev <eam@7ka.mipt.ru> writes:
Eugene> these are the same. 'for' and 'foreach' are synonyms
Although a "for" loop is distinct from a "foreach" loop.
Sometimes, you spell it f-o-r, and pronounce it "foreach".
print "Just another Perl hacker,"; # the original
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
------------------------------
Date: 16 Aug 2004 09:31:35 -0700
From: wherrera@lynxview.com (Bill)
Subject: Re: has anybody write bioinformatics programme with perl
Message-Id: <239ce42f.0408160831.15971842@posting.google.com>
"hugo" <hugoyg@163.com> wrote in message news:<2oba7mF8rs97U1@uni-berlin.de>...
> let talk about bioinformatics more.
Try the newsgroup sci.med.informatics too.
------------------------------
Date: Mon, 16 Aug 2004 14:32:34 +0100
From: Graham Wood <Graham.T.removethis.Wood@oracle.andthis.com>
Subject: How do I pick up existing objects in event handling code?
Message-Id: <8S2Uc.30$bW.78@news.oracle.com>
I've written an FTP client using the GUI Loft and Net::FTP. I've
managed to get the program to work by scoping the $ftp object with "our"
but I don't think this is how you are supposed to do it.
Here's an artist's impression of what I'm doing now:
our $ftp= Net::FTP->new("hostname")|| die "Can't create FTP object";
sub ::btnChdir_Click{
our $ftp;
# get $path from value in a text box
$ftp->cwd("$path");
}
sub ::btnOK_Click{
our $ftp;
$ftp->put("$file");
}
sub ::btnDisconnect_Click{
our $ftp;
$ftp->quit();
}
I know that I could pass the $ftp object as an argument to subroutines
if I were calling them from my script but in this event driven model,
how do I elegantly pick up the value of the existing ftp object without
letting it all hang out in this unseemly fashion?
I notice that the gui $win object is picked up with code like this:
defined(my $win = $Win32::GUI::Loft::window(winCopyFiles})
or return (1);
Can I do something similar with Net::FTP objects like
defined(my $ftp = $Net::FTP);
Any hints gratefully accepted.
Thanks
Graham
------------------------------
Date: Mon, 16 Aug 2004 18:45:56 GMT
From: "http://links.i6networks.com" <SaveWorldFromAids@alexa.com>
Subject: Is GD library independent?
Message-Id: <Eh7Uc.142$D6M1.74@news04.bloor.is.net.cable.rogers.com>
Do I need to install ImageMagick for using the GD library? Does GD library
require anything else beyond a standard Perl?
------------------------------
Date: Mon, 16 Aug 2004 21:44:10 +0200
From: "JJ" <geenbestaandadres@lycos.nl>
Subject: Re: Is GD library independent?
Message-Id: <41210e9c$0$62371$5fc3050@dreader2.news.tiscali.nl>
No, I've used it for years on the following config:
Windows 2000/xp/2003
Activeperl
VPM to install the module
GD module
It works fine
"http://links.i6networks.com" <SaveWorldFromAids@alexa.com> schreef in
bericht news:Eh7Uc.142$D6M1.74@news04.bloor.is.net.cable.rogers.com...
> Do I need to install ImageMagick for using the GD library? Does GD library
> require anything else beyond a standard Perl?
>
>
------------------------------
Date: Mon, 16 Aug 2004 19:12:29 -0000
From: "gnari" <gnari@simnet.is>
Subject: Re: Is GD library independent?
Message-Id: <cfr0qv$lit$1@news.simnet.is>
"http://links.i6networks.com" <SaveWorldFromAids@alexa.com> wrote in message
news:Eh7Uc.142$D6M1.74@news04.bloor.is.net.cable.rogers.com...
> Do I need to install ImageMagick for using the GD library? Does GD library
> require anything else beyond a standard Perl?
actually, it requires the, er, GD library. (libgd)
gnari
------------------------------
Date: Mon, 16 Aug 2004 16:00:41 +0200
From: Reto Hersiczky <spam@infocopter.ch>
Subject: Re: LWP & Javascript
Message-Id: <4120be09$0$4887$5402220f@news.sunrise.ch>
Perly wrote:
> Hi Everyone,
> I want to know if there's any perl module that can handle submitting
> javascripted form..
>
LWP doesn't have to handle nor parse JavaScript for any kind
of a CGI submission.
If you're trying to simulate the Browser's activity I suggest to
replace the action path of that form with a CGI script you have
under control. Then, write each CGI key and its value into a log.
If you're using CPAN's CGI.pm there is a generic method
$q->all_parameters which returns a hash reference to all
received key pairs.
If my guess did not match your question please be more precisely.
--retoh
------------------------------
Date: 16 Aug 2004 21:40:09 GMT
From: ctcgag@hotmail.com
Subject: Materializing an indirect sort using only swap
Message-Id: <20040816174009.455$wV@newsreader.com>
Good day, all.
I have a object which has sub-objects. The object only provides
one way to re-order sub-objects: a somewhat expensive swap operation.
I have code that does an indirect sort of the sub-objects:
my @x;
foreach my $i (1..$o->nofSub()) {
push @x, compute_value($o,$i);
};
my @idx = "dummy", sort {$x[$a]<=>$x[$b]} 0..$#x;
Now, I merely have to use @idx as a translation table so that I can access
sub-objects as if they were sorted. Works great for the most part, but
I've reached a point where that isn't good enough and I need to materialize
the sort into the object itself. So I'm trying to use the transformation
implied in @idx to apply a proper series of $o->swap($foo,$bar) operations
to put the sub-objects in order.
All the easy solutions I've come up with are about equivalent to selection
sort (O(N) swaps, O(N**2) comparisons). In this case, that will work
(because the nofSub never gets more than a few hundred), but its inelegance
and poor scaling offend me.
One solution is to add hooks into the object code to allow more efficient
re-organization, but I know that there must be a better, elegant way to do
it with just @idx and swap(). Any clues?
Thanks,
Xho
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
------------------------------
Date: 16 Aug 2004 14:10:57 -0700
From: laredotornado@zipmail.com (D. Alvarado)
Subject: One liner for renaming files
Message-Id: <9fe1f2ad.0408161310.1a09d7dc@posting.google.com>
Hello,
I am looking for a one line command that I could run with perl to
rename a group of files. The desired outcome is
start end
----- ---
ctf_005.liv ctf05cae002.liv
ctf_006.liv ctf05cae003.liv
ctf_007.liv ctf05cae004.liv
ctf_008.liv ctf05cae005.liv
and so on.
Any advice is greatly appreciated, - Dave
------------------------------
Date: 16 Aug 2004 10:12:18 -0700
From: sroth1979@hotmail.com (Scott)
Subject: Parsing a text file into an array
Message-Id: <26dbb845.0408160912.6a549090@posting.google.com>
I having a bit of trouble trying to parse...
789798798 test,test 12/5/3005
with tabs between each column. Does any one have some suggestions?
------------------------------
Date: Mon, 16 Aug 2004 13:20:33 -0400
From: Paul Lalli <mritty@gmail.com>
Subject: Re: Parsing a text file into an array
Message-Id: <20040816131925.Y2996@barbara.cs.rpi.edu>
On Mon, 16 Aug 2004, Scott wrote:
> I having a bit of trouble trying to parse...
>
> 789798798 test,test 12/5/3005
>
> with tabs between each column. Does any one have some suggestions?
read the documentation for the 'split' function:
perldoc -f split
Then make an attempt. If you can't get it working, show what you have and
ask for assistance in fixing your code.
Paul Lalli.
------------------------------
Date: Mon, 16 Aug 2004 09:27:56 -0700
From: Jim Gibson <jgibson@mail.arc.nasa.gov>
Subject: Re: Problems with proxy ..
Message-Id: <160820040927568360%jgibson@mail.arc.nasa.gov>
In article <2ca34262.0408151150.168bfb2d@posting.google.com>, Idan Jan
<idan.jan@gmail.com> wrote:
> Hi all,
> Hope you could help me with this problem.
> I have the following code (please forgive the ugliness) :
>
> == code start ==
> $url = 'http://www.alexa.com/data/details/traffic_details?q=&url=cnn.com';
>
> $ua = LWP::UserAgent->new;
> $ua->proxy(http => $proxyserver);
> $req = HTTP::Request->new(GET => $url);
> $file = $ua->request($req)->as_string;
>
> print "$file\n";
> == code end ==
>
> I get the following output:
> === output start ===
> HTTP/1.0 202 Accepted
> Date: Sun, 15 Aug 2004 19:20:54 GMT
> Server:
> Content-Length: 0
> Content-Type: text/text
> Client-Date: Sun, 15 Aug 2004 20:23:44 GMT
> Client-Peer: 80.121.233.206:8000
> Client-Response-Num: 1
> Proxy-Connection: close
> X-Cache: MISS from oxo.demo.com
> === output end ===
>
> As you can see, I don't get the actual http data from the site, only
> the above output. With other $urls this code works perfectly, but with
> this alexa url, I only get the above output.
>
> As far as I know, the HTTP 202 code isn't an Error code, so I really
> can't tell what's the problem... ?
A search on google for '202 accepted' turns up:
"202 Accepted
"The request has been accepted for processing, but the processing has
not been completed. The request MAY or MAY NOT eventually be acted
upon, as it MAY be disallowed when processing actually takes place.
There is no facility for re-sending a status code from an
asynchronous operation such as this.
"The 202 response is intentionally non-committal. Its purpose is to
allow a server to accept a request for some other process (perhaps a
batch-oriented process that is only run once per day) without
requiring that the user agent's connection to the server persist
until the process is completed. The entity returned with this
response SHOULD include an indication of the request's current status
and either a pointer to a status monitor or some estimate of when the
user can expect the request to be fulfilled."
So there is nothing really wrong, just that the server doesn't feel
like providing any pages at the moment. :^)
It sounds like this is more of an HTTP question than a Perl one. Or
perhaps a question should be directed to the maintainer of this
website.
------------------------------
Date: Mon, 16 Aug 2004 15:40:18 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Regexp: substituting \n with <br /> except in certain places
Message-Id: <2obs7iF8soh3U1@uni-berlin.de>
Sandman wrote:
> Textblock (indented for clarity):
>
> Hello, my nickname is Sandman, here is
> a list of things I like:
>
> <ol>
> <li> Perl
> <li> PHP
> <li> MySQL
> </ol>
>
> I want to replace newlines with "<br />\n" in this textblock, for
> displaying it to a browser - but I don't want to replace it inside
> some specified html-tags - in this case "ol", but also "ul", "pre"
> and "xmp".
>
> So, the resulting text block should be:
>
> Hello, my nickname is Sandman, here is<br />
> a list of things I like:<br />
> <br />
> <ol>
> <li> Perl
> <li> PHP
> <li> MySQL
> </ol>
How about:
$text =~ s{(<(ol|ul|pre|xmp)[^>]*>.*?</\2>\n?)|\n}
{ $1 ? $1 : "<br />\n" }egis;
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Mon, 16 Aug 2004 19:07:01 -0000
From: "gnari" <gnari@simnet.is>
Subject: Re: Regexp: substituting \n with <br /> except in certain places
Message-Id: <cfr0go$li0$1@news.simnet.is>
"Gunnar Hjalmarsson" <noreply@gunnar.cc> wrote in message
news:2obs7iF8soh3U1@uni-berlin.de...
> Sandman wrote:
> > Textblock (indented for clarity):
> >
> > Hello, my nickname is Sandman, here is
> > a list of things I like:
> >
> > <ol>
> > <li> Perl
> > <li> PHP
> > <li> MySQL
> > </ol>
> >
> > I want to replace newlines with "<br />\n" in this textblock, for
> > displaying it to a browser - but I don't want to replace it inside
> > some specified html-tags - in this case "ol", but also "ul", "pre"
> > and "xmp".
> >
> > So, the resulting text block should be:
> >
> > Hello, my nickname is Sandman, here is<br />
> > a list of things I like:<br />
> > <br />
> > <ol>
> > <li> Perl
> > <li> PHP
> > <li> MySQL
> > </ol>
>
> How about:
>
> $text =~ s{(<(ol|ul|pre|xmp)[^>]*>.*?</\2>\n?)|\n}
> { $1 ? $1 : "<br />\n" }egis;
not bad.
if an extra '<br />' is acceptable after the end tag,
we can get rid of the /e:
$text =~ s{(<(ol|ul|pre|xmp)[^>]*>.*?</\2>\n?)|\n}
{<br />\n}gis;
gnari
------------------------------
Date: Mon, 16 Aug 2004 22:15:52 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Regexp: substituting \n with <br /> except in certain places
Message-Id: <2ocjeiF8rlksU1@uni-berlin.de>
gnari wrote:
> Gunnar Hjalmarsson wrote:
>>
>>How about:
>>
>> $text =~ s{(<(ol|ul|pre|xmp)[^>]*>.*?</\2>\n?)|\n}
>> { $1 ? $1 : "<br />\n" }egis;
>
> not bad.
Thanks. :)
> if an extra '<br />' is acceptable after the end tag,
> we can get rid of the /e:
>
> $text =~ s{(<(ol|ul|pre|xmp)[^>]*>.*?</\2>\n?)|\n}
> {<br />\n}gis;
Don't understand. That would not just add extra '<br />'s, but it
would remove the identified HTML blocks.
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Mon, 16 Aug 2004 22:01:22 -0000
From: "gnari" <gnari@simnet.is>
Subject: Re: Regexp: substituting \n with <br /> except in certain places
Message-Id: <cfranl$mkf$1@news.simnet.is>
"Gunnar Hjalmarsson" <noreply@gunnar.cc> wrote in message
news:2ocjeiF8rlksU1@uni-berlin.de...
> gnari wrote:
> > Gunnar Hjalmarsson wrote:
> >>
> >>How about:
> >>
> >> $text =~ s{(<(ol|ul|pre|xmp)[^>]*>.*?</\2>\n?)|\n}
> >> { $1 ? $1 : "<br />\n" }egis;
> >
> > not bad.
>
> Thanks. :)
>
> > if an extra '<br />' is acceptable after the end tag,
> > we can get rid of the /e:
> >
> > $text =~ s{(<(ol|ul|pre|xmp)[^>]*>.*?</\2>\n?)|\n}
> > {<br />\n}gis;
>
> Don't understand. That would not just add extra '<br />'s, but it
> would remove the identified HTML blocks.
indeed. of course I meant
$text =~ s{(<(ol|ul|pre|xmp)[^>]*>.*?</\2>\n?)|\n}
{$1<br />\n}gis;
gnari
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc. For subscription or unsubscription requests, send
#the single line:
#
# subscribe perl-users
#or:
# unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.
NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.
#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V10 Issue 6871
***************************************