[19229] in Perl-Users-Digest
Perl-Users Digest, Issue: 1424 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Aug 1 18:10:31 2001
Date: Wed, 1 Aug 2001 15:10:13 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <996703812-v10-i1424@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Wed, 1 Aug 2001 Volume: 10 Number: 1424
Today's topics:
Re: newbe question splitting a string into two differen <Tassilo.Parseval@post.rwth-aachen.de>
Re: newbe question splitting a string into two differen <jeff@vpservices.com>
Re: newbe question splitting a string into two differen <ren@tivoli.com>
Re: newbe question splitting a string into two differen (Charles DeRykus)
Re: newbe question splitting a string into two differen <Tassilo.Parseval@post.rwth-aachen.de>
Re: newbe question splitting a string into two differen <Tassilo.Parseval@post.rwth-aachen.de>
Oh and another quick question <nathan.randle@ntlworld.com>
Re: Oh and another quick question <bart@nijlen.com>
Re: Oh and another quick question <me@my_no_spam.org>
Re: Oh and another quick question (Tad McClellan)
Re: Oh and another quick question <james@zephyr.org.uk>
read files into arrays... <nathan.randle@ntlworld.com>
Re: read files into arrays... <Tassilo.Parseval@post.rwth-aachen.de>
Re: read files into arrays... <mjcarman@home.com>
Re: read files into arrays... <Tassilo.Parseval@post.rwth-aachen.de>
Splitting a text list into smaller lists? ctverlane@NOSPAM.blackdahlia.zzn.com
Re: Strange problem... <mischief@velma.motion.net>
The perlish way to write this? <a@b.c>
Re: Using CSS with CGI.pm slash@dot.c.o.m.org
Re: Using CSS with CGI.pm <mischief@velma.motion.net>
Re: What's the regular expression to check emails and <iltzu@sci.invalid>
Re: What's the regular expression to check emails and <ren@tivoli.com>
Re: What's the regular expression to check emails and (Randal L. Schwartz)
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 01 Aug 2001 20:36:14 +0200
From: Tassilo von Parseval <Tassilo.Parseval@post.rwth-aachen.de>
Subject: Re: newbe question splitting a string into two different variables
Message-Id: <3B684C1E.5030301@post.rwth-aachen.de>
Uri Guttman wrote:
>>>>>>"TvP" == Tassilo von Parseval <Tassilo.Parseval@post.rwth-aachen.de> writes:
>>>>>>
>
> TvP> I better should have written an array is undefined when its
> TvP> length is zero.
>
>that still is wrong. undef @array is very different than @array = ().
>
>the former deletes all storage associated with the array. the latter
>only sets its length to 0, while its storage is still kept for reuse
>(assuming you stuff it with data).
>
*sigh* After a few quick tests with if (defined...) I hope I have
finally understood this. These are really subtle differences. I remember
once having had a serious problem with if (defined $var) versus if
($var) which did not seem to be the same at all under certain
circumstances. I was at this time only able to make it work by trying
either of it till it worked.
Thanks for your making this clearer to me.
Tassilo
--
FORTRAN is not a flower but a weed -- it is hardy, occasionally blooms,
and grows in every computer.
-- A.J. Perlis
------------------------------
Date: Wed, 01 Aug 2001 12:25:49 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: newbe question splitting a string into two different variables
Message-Id: <3B6857BD.70A38A33@vpservices.com>
Tassilo von Parseval wrote:
>
> Uri Guttman wrote:
>
> >>>>>>"TvP" == Tassilo von Parseval <Tassilo.Parseval@post.rwth-aachen.de> writes:
> >>>>>>
> >
> > TvP> I better should have written an array is undefined when its
> > TvP> length is zero.
> >
> >that still is wrong. undef @array is very different than @array = ().
> >
> >the former deletes all storage associated with the array. the latter
> >only sets its length to 0, while its storage is still kept for reuse
> >(assuming you stuff it with data).
> >
>
> *sigh* After a few quick tests with if (defined...) I hope I have
> finally understood this. These are really subtle differences. I remember
> once having had a serious problem with if (defined $var) versus if
> ($var) which did not seem to be the same at all under certain
> circumstances. I was at this time only able to make it work by trying
> either of it till it worked.
Yeah, that bit me a few times too. Here's something that helps me
remember how to handle it:
my($ary1,$ary2,$ary3);
@$ary1 = qw(a b c);
@$ary2 = ();
my $count;
for ($ary1,$ary2,$ary3) {
print ++$count . ". ";
print "undefined, " unless defined $_;
print "empty, " if defined $_ and ! scalar @$_;
# print "empty, " if ! scalar @$_; # WRONG
(defined $_ and scalar @$_)
? print "has elements"
: print "doesn't have elements";
print "\n";
}
That prints:
1. has elements
2. empty, doesn't have elements
3. undefined, doesn't have elements
So all in all, the "if defined $x and scalar @$x" gives you a yes/no to
the question "do I have an array with something in it?" without falling
into the trap of trying to measure the length of an undefined arrayref.
If you tried something like the line marked WRONG, you'd get an
"uninitialized value" warning though the results would be correct.
--
Jeff
------------------------------
Date: 01 Aug 2001 12:41:30 -0500
From: Ren Maddox <ren@tivoli.com>
Subject: Re: newbe question splitting a string into two different variables
Message-Id: <m3u1zrbrud.fsf@dhcp9-161.support.tivoli.com>
On Wed, 01 Aug 2001, Tassilo.Parseval@post.rwth-aachen.de wrote:
> I better should have written an array is undefined when its length
> is zero.
Well, sort of. Really it is just empty when its length is zero. Here
is a relevant passage from the description of defined() in
perlfunc(1):
Use of `defined' on aggregates (hashes and arrays)
is deprecated. It used to report whether memory
for that aggregate has ever been allocated. This
behavior may disappear in future versions of Perl.
In particular:
my @a = (1);
shift @a;
print scalar @a, " ", defined @a ? "defined" : "undefined", "\n";
prints:
0 defined
(along with a warning if warnings are enabled)
Unless, of course, your use of "undefined" was more generic. But
"undef" and "defined" have very specific meanings in Perl.
--
Ren Maddox
ren@tivoli.com
------------------------------
Date: Wed, 1 Aug 2001 19:57:06 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: newbe question splitting a string into two different variables
Message-Id: <GHEnF6.K3K@news.boeing.com>
In article <3B682DEA.5050308@post.rwth-aachen.de>,
Tassilo von Parseval <Tassilo.Parseval@post.rwth-aachen.de> wrote:
>...
>
>I better should have written an array is undefined when its length is zero.
Actually, that's not the case if you're referring to Perl's
C<defined> semantics:
perl -wle '@a=(1);@a=();print "def. but 0" if defined @a && !@a'
Here's the section from perlfunc:
Currently, using C<defined()> on an entire array or hash
reports whether memory for that aggregate has ever been
allocated. So an array you set to the empty list appears
undefined initially, and one that once was full and that
you then set to the empty list still appears defined.
--
Charles DeRykus
------------------------------
Date: Wed, 01 Aug 2001 22:57:50 +0200
From: Tassilo von Parseval <Tassilo.Parseval@post.rwth-aachen.de>
Subject: Re: newbe question splitting a string into two different variables
Message-Id: <3B686D4E.1030206@post.rwth-aachen.de>
Jeff Zucker wrote:
>Tassilo von Parseval wrote:
>
>>*sigh* After a few quick tests with if (defined...) I hope I have
>>finally understood this. These are really subtle differences. I remember
>>once having had a serious problem with if (defined $var) versus if
>>($var) which did not seem to be the same at all under certain
>>circumstances. I was at this time only able to make it work by trying
>>either of it till it worked.
>>
>
>Yeah, that bit me a few times too. Here's something that helps me
>remember how to handle it:
>
>
[code snipped]
>
>That prints:
>
> 1. has elements
> 2. empty, doesn't have elements
> 3. undefined, doesn't have elements
>
>So all in all, the "if defined $x and scalar @$x" gives you a yes/no to
>the question "do I have an array with something in it?" without falling
>into the trap of trying to measure the length of an undefined arrayref.
>If you tried something like the line marked WRONG, you'd get an
>"uninitialized value" warning though the results would be correct.
>
Thank you, that looks sane to me. I am quite confident that another
source of error has been wiped out for me now.
Tassilo
--
We were happily married for eight months. Unfortunately, we were married
for four and a half years.
-- Nick Faldo
------------------------------
Date: Wed, 01 Aug 2001 23:02:09 +0200
From: Tassilo von Parseval <Tassilo.Parseval@post.rwth-aachen.de>
Subject: Re: newbe question splitting a string into two different variables
Message-Id: <3B686E51.2060309@post.rwth-aachen.de>
Charles DeRykus wrote:
>In article <3B682DEA.5050308@post.rwth-aachen.de>,
>Tassilo von Parseval <Tassilo.Parseval@post.rwth-aachen.de> wrote:
>
>>...
>>
>>I better should have written an array is undefined when its length is zero.
>>
>
>Actually, that's not the case if you're referring to Perl's
>C<defined> semantics:
>
Well, actually I was and indeed proved wrong.
>
>
>perl -wle '@a=(1);@a=();print "def. but 0" if defined @a && !@a'
>
>Here's the section from perlfunc:
>
> Currently, using C<defined()> on an entire array or hash
> reports whether memory for that aggregate has ever been
> allocated. So an array you set to the empty list appears
> undefined initially, and one that once was full and that
> you then set to the empty list still appears defined.
>
Wait a min. Would this mean, that the first occurance of
my @array = ( );
eventually is undefined? From what Jeff Zucker wrote it appeared to be
defined but empty.
Tassilo
--
We were happily married for eight months. Unfortunately, we were married
for four and a half years.
-- Nick Faldo
------------------------------
Date: Wed, 1 Aug 2001 20:31:49 +0100
From: "Nathan Randle" <nathan.randle@ntlworld.com>
Subject: Oh and another quick question
Message-Id: <YPY97.20027$ip4.5131157@news2-win.server.ntlworld.com>
When modifying a file i've opened it using
open(filehandle,">>file.dat");
when i write to one of the lines does it overwrite that line or jsut add to
it ??
If it adds to it how can i delete the current contents of the line then put
in the new contents ?
thanx AGAIN
Nathan
------------------------------
Date: Wed, 01 Aug 2001 19:58:41 GMT
From: "Bart Van der Donck" <bart@nijlen.com>
Subject: Re: Oh and another quick question
Message-Id: <RbZ97.6102$lB.1085346@afrodite.telenet-ops.be>
> open(filehandle,">>file.dat");
> when i write to one of the lines does it overwrite that line or jsut add
to
> it ??
This line will add new contents after the last character of the file.
> If it adds to it how can i delete the current contents of the line then
put
> in the new contents ?
open(filehandle,">file.dat");
This will erase the existing content and write the new content.
Bart
>
> thanx AGAIN
> Nathan
>
>
------------------------------
Date: Wed, 01 Aug 2001 16:17:06 -0400
From: Dave VP <me@my_no_spam.org>
Subject: Re: Oh and another quick question
Message-Id: <3B6863C2.4834F058@my_no_spam.org>
Nathan Randle wrote:
>
> When modifying a file i've opened it using
>
> open(filehandle,">>file.dat");
>
> when i write to one of the lines does it overwrite that line or jsut add to
> it ??
>
> If it adds to it how can i delete the current contents of the line then put
> in the new contents ?
>
> thanx AGAIN
> Nathan
The following may offer additional clues:
perldoc -q "How do I change one line in a file"
------------------------------
Date: Wed, 1 Aug 2001 15:47:47 -0400
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Oh and another quick question
Message-Id: <slrn9mgn73.nnu.tadmc@tadmc26.august.net>
Nathan Randle <nathan.randle@ntlworld.com> wrote:
>When modifying a file i've opened it using
>
>open(filehandle,">>file.dat");
You should always, yes *always*, check the return value from open():
open(FILEHANDLE, '>>file.dat') or die "could not open 'file.dat' $!";
UPPER CASE filehandles are a good idea.
I use single quotes unless I need the extra stuff that comes
with double quotes.
>when i write to one of the lines does it overwrite that line or jsut add to
>it ??
What happened when you tried it?
>If it adds to it how can i delete the current contents of the line then put
^^^^^^
>in the new contents ?
perldoc -q delete
"How do I change one line in a file/delete a line in a
file/insert a line in the middle of a file/append to the
beginning of a file?"
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Wed, 1 Aug 2001 22:32:33 +0100
From: James Coupe <james@zephyr.org.uk>
Subject: Re: Oh and another quick question
Message-Id: <dt+nWUexVHa7EwUW@gratiano.zephyr.org.uk>
In message <slrn9mgn73.nnu.tadmc@tadmc26.august.net>, Tad McClellan
<tadmc@augustmail.com> writes
>Nathan Randle <nathan.randle@ntlworld.com> wrote:
>>When modifying a file i've opened it using
>>
>>open(filehandle,">>file.dat");
>
>You should always, yes *always*, check the return value from open():
Unless you were writing a question of "What is wrong with the following
Perl code?" surely?
Semi-colon dash bracket etc.
--
James Coupe PGP Key: 0x5D623D5D
EBD690ECD7A1F
HEY, MOM! I FOUND SOME OF THOSE PEOPLE ON THE INTERNET B457CA213D7E6
YOU WERE TELLING ME TO NOT TALK TO! 68C3695D623D5D
------------------------------
Date: Wed, 1 Aug 2001 20:07:22 +0100
From: "Nathan Randle" <nathan.randle@ntlworld.com>
Subject: read files into arrays...
Message-Id: <0tY97.19918$ip4.5103478@news2-win.server.ntlworld.com>
is there a way of reading specific lines from a text file into an array
Eg. read lines 10 - 30 of data.dat
In perl form obviously. I used that just to illustrate what i mean.
Cheerz.
Nathan
------------------------------
Date: Wed, 01 Aug 2001 21:18:20 +0200
From: Tassilo von Parseval <Tassilo.Parseval@post.rwth-aachen.de>
Subject: Re: read files into arrays...
Message-Id: <3B6855FC.9080604@post.rwth-aachen.de>
Nathan Randle wrote:
>is there a way of reading specific lines from a text file into an array
>
>Eg. read lines 10 - 30 of data.dat
>
Yes.
>In perl form obviously. I used that just to illustrate what i mean.
>
Use an array-slice for that:
open FILE, "data.dat" or die "Error: $!";
my @array = (<FILE>)[9 .. 29];
Tassilo
--
BEWARE! People acting under the influence of human nature.
------------------------------
Date: Wed, 01 Aug 2001 14:44:10 -0500
From: Michael Carman <mjcarman@home.com>
Subject: Re: read files into arrays...
Message-Id: <3B685C0A.857EA8D5@home.com>
Tassilo von Parseval wrote:
>
> Nathan Randle wrote:
>
>> is there a way of reading specific lines from a text file into
>> an array
>>
>> Eg. read lines 10 - 30 of data.dat
>>
>
> Use an array-slice for that:
>
> open FILE, "data.dat" or die "Error: $!";
> my @array = (<FILE>)[9 .. 29];
Ug. That makes Perl slurp up the entire file when you only want a few
lines.
my @array;
while (<FILE>) {
push(@array, $_) if (9 .. 29);
last if $. >= 29; # Abort file read
}
-mjc
------------------------------
Date: Wed, 01 Aug 2001 22:51:28 +0200
From: Tassilo von Parseval <Tassilo.Parseval@post.rwth-aachen.de>
Subject: Re: read files into arrays...
Message-Id: <3B686BD0.4020300@post.rwth-aachen.de>
Michael Carman wrote:
>Tassilo von Parseval wrote:
>
>>Nathan Randle wrote:
>>
>>>is there a way of reading specific lines from a text file into
>>>an array
>>>
>>>Eg. read lines 10 - 30 of data.dat
>>>
>>Use an array-slice for that:
>>
>>open FILE, "data.dat" or die "Error: $!";
>>my @array = (<FILE>)[9 .. 29];
>>
>
>Ug. That makes Perl slurp up the entire file when you only want a few
>lines.
>
True, I did not think of that. Yet, it looks wonderfully obscure when
having a closer look at it. ;-)
Tassilo
--
We were happily married for eight months. Unfortunately, we were married
for four and a half years.
-- Nick Faldo
------------------------------
Date: 1 Aug 2001 20:26:52 GMT
From: ctverlane@NOSPAM.blackdahlia.zzn.com
Subject: Splitting a text list into smaller lists?
Message-Id: <9k9omc$m86$1@news.netmar.com>
I apologize in advance for the cluelessness of this question, but I'm
desperate, so here goes.
I'm an Oracle dba. I have a long list of users (25000) of them, in a
delimited text file. What I want to do is use Perl to take the long list and
divide it up into 500 lists of 50 users each. So the task breaks down to 1)
dividing the list into groups of 50, using the delimiter to show where each
username ends, and then 2) writing each list to a separate file.
Here is my halting attempt at it:
#!/usr/bin/perl -w
# Read the file of 25000 users from stdin:
while ($a = <STDIN>) {
# Parse the line, using the numeral 4 as the delimiter.
@a = split( /4/, $a, 50);
foreach $a (@a) {
print "$a";
}
}
exit;
For some bizarre reason, this script when run counts out a list of forty-two
users, not fifty. I have no idea why. And when I put a loop in, the script
just iterated over the first forty-two users repeatedly (never moved down
further in the file.) I haven't restored the loop or the print-to-a-file
function yet (the writing to a file part works fine) because I think I need
to figure out what I'm doing wrong in this part first.
I've been combing through the perldocs and the blue camel book without any
luck. I know I must be missing something big and obvious here, but if anyone
could offer any advice or suggestions to point me in the right direction, I
would be very humbly grateful.
Thanks,
CT
----- Posted via NewsOne.Net: Free (anonymous) Usenet News via the Web -----
http://newsone.net/ -- Free reading and anonymous posting to 60,000+ groups
NewsOne.Net prohibits users from posting spam. If this or other posts
made through NewsOne.Net violate posting guidelines, email abuse@newsone.net
------------------------------
Date: Wed, 01 Aug 2001 21:58:45 -0000
From: Chris Stith <mischief@velma.motion.net>
Subject: Re: Strange problem...
Message-Id: <tmgusl61e2de84@corp.supernews.com>
nobull@mail.com wrote:
> "Nathan Randle" <nathan.randle@ntlworld.com> writes:
> I'd guess most lurkers in this group would also be able to find
> several classic newbie-isms (or realy a learning-from-a-bad-book-ism)
> in your code right off.
I think the code below is more likely a learning-from-a-bad-book-ism
than a newbie-ism.
>> #!/usr/bin/perl
> Not enabled warning and strictures.
>> print "Content-type:text/html\n\n";
>>
>> read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
>> @checks = split(/&/, $buffer);
>> foreach $check (@checks) {
>> ($name, $value) = split(/=/, $pair);
>> $value =~ tr/+/ /;
>> $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
>> $FORM{$name} = $value;
>> }
> Rolling your own CGI implementation.
I don't think the OP rolled this. I've seen this exact same code,
right down to the same variables. I'm not sure from where it comes,
but it must be coming from a published source.
Chris
--
Product shown enlarged to make you think you're getting more.
------------------------------
Date: Wed, 01 Aug 2001 14:51:08 -0700
From: BCC <a@b.c>
Subject: The perlish way to write this?
Message-Id: <3B6879CC.32719BCD@b.c>
Hi,
Is this the best way to write this sub? If not what would be an
improvement?
sub imageButton {
my ($href, $image, $alt, $border, $align) = @_;
$alt = "" if !$alt;
$border = "0" if !$border;
$align = "abscenter" if !$align;
print "<a href=$href><img src=$image align=$align border=$border
alt=\'$alt\'></a>";
}
Thanks!
------------------------------
Date: Wed, 01 Aug 2001 20:57:39 GMT
From: slash@dot.c.o.m.org
Subject: Re: Using CSS with CGI.pm
Message-Id: <3b686c9a.3889468@news.freeserve.co.uk>
On Mon, 30 Jul 2001 21:16:27 -0700, "Godzilla!" <godzilla@stomp.stomp.tokyo> wrote:
>Kenneth Eide wrote:
>
>(snipped)
>
>> I want to use Cascading Style Sheets with my CGI script but I'm having
>> trouble findig out how to specify how to use css, and what file to use.
>> I'm writing my CGI with CGI.pm.
>
>You may discover trying to print a server side include
[blah blah blah]
It's funny, I'm sure I remembered you stating real programmers don't use
libraries/modules a while back, and you actually wrote everything yourself (which
seems a little hard to believe, given the rather poor code you post to this group).
Yet now here you are babbling about the cgi module. Were you lying back then, or are
you lying now?
------------------------------
Date: Wed, 01 Aug 2001 21:54:59 -0000
From: Chris Stith <mischief@velma.motion.net>
Subject: Re: Using CSS with CGI.pm
Message-Id: <tmguljndhc5a19@corp.supernews.com>
slash@dot.c.o.m.org wrote:
> On Mon, 30 Jul 2001 21:16:27 -0700, "Godzilla!" <godzilla@stomp.stomp.tokyo> wrote:
>>Kenneth Eide wrote:
>>
>>(snipped)
>>
>>> I want to use Cascading Style Sheets with my CGI script but I'm having
>>> trouble findig out how to specify how to use css, and what file to use.
>>> I'm writing my CGI with CGI.pm.
>>
>>You may discover trying to print a server side include
> [blah blah blah]
> It's funny, I'm sure I remembered you stating real programmers don't use
> libraries/modules a while back, and you actually wrote everything yourself (which
> seems a little hard to believe, given the rather poor code you post to this group).
> Yet now here you are babbling about the cgi module. Were you lying back then, or are
> you lying now?
I post this not specifically to defend Kira, but you took some text
out of her post, out of context, and ccused her of lying based on it.
If you would be so kind as to read a post before you make incindiary
comments about it, you would realize that Kira does suggest writing
the CGI code and not using CGI.pm -- in fact, she calls it cgi.poopmaker
or something to that effect.
She also made a secondary suggestion that if the user wants to use
CGI.pm, that the user might be helped by reading the documentation.
I find no discrepencies between a poster suggesting his or her own
preferred method of doing something and also suggesting how to proceed
down the OP's current course.
What I find offensive in this thread is that you, 'slash', make
every effort to belittle another poster based on a poor or partial
reading of a post. Kira's advice may not be mainstream - she
might not even be very polite all the time - but she shouldn't be
ridiculed for something she plainly did not do.
Chris Stith
--
Programming is a tool. A tool is neither good nor evil. It is
the user who determines how it is used and to what ends.
------------------------------
Date: 1 Aug 2001 18:58:54 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: What's the regular expression to check emails and to remove html
Message-Id: <996689523.26104@itz.pp.sci.fi>
In article <slrn9mee1h.d4m.abigail@alexandra.xs4all.nl>, Abigail wrote:
>Miriam Raphael-Roberts (miriamraphael@yahoo.com) wrote on MMDCCCLXXXII
>September MCMXCIII in <URL:news:748729f5.0107220938.385b2e0f@posting.google.com>:
>%% Hi,
>%% I know that you can remove HTML from text by using one regular expression.
>
>Really? I'd like to see it. Most attempts don't even get close.
Well, s%<(-?[^>"'-]|-?"[^"]*"|-?'[^']*'|--(-?[^-])*--)*(>|$)%%g should
handle any valid tags and comments. Extending it to handle marked
sections, null-end-tags, and any other SGML oddities one could think of
is left as an exercise for the reader.
The main difficulty it has is with CDATA, where a stray <" sequence
might trick it into deleting more than it should. In any case, the
remaining string will contain no less-than signs, and therefore no
HTML tags.
Alone, the regex admittedly has little practical value. However, the
right side of the substitution may be changed to allow a limited set of
tags to pass, in which case it _can_ be useful
Point? Well, nothing. You asked to see a regex that can strip HTML
tags from a string, or at least get close. I had one lying around.
--
Ilmari Karonen -- http://www.sci.fi/~iltzu/
"Get real! This is a discussion group, not a helpdesk. You post something,
we discuss its implications. If the discussion happens to answer a question
you've asked, that's incidental." -- nobull in comp.lang.perl.misc
------------------------------
Date: 01 Aug 2001 15:29:18 -0500
From: Ren Maddox <ren@tivoli.com>
Subject: Re: What's the regular expression to check emails and to remove html
Message-Id: <m3lml3ikwx.fsf@dhcp9-161.support.tivoli.com>
On 1 Aug 2001, iltzu@sci.invalid wrote:
> Well, s%<(-?[^>"'-]|-?"[^"]*"|-?'[^']*'|--(-?[^-])*--)*(>|$)%%g
> should handle any valid tags and comments. Extending it to handle
> marked sections, null-end-tags, and any other SGML oddities one
> could think of is left as an exercise for the reader.
Doesn't handle dashes embedded within comments:
<!-- like -- this -->
That is legal HTML, isn't it?
--
Ren Maddox
ren@tivoli.com
------------------------------
Date: 01 Aug 2001 14:13:27 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: What's the regular expression to check emails and to remove html
Message-Id: <m1puafpjpk.fsf@halfdome.holdit.com>
>>>>> "Ren" == Ren Maddox <ren@tivoli.com> writes:
Ren> On 1 Aug 2001, iltzu@sci.invalid wrote:
>> Well, s%<(-?[^>"'-]|-?"[^"]*"|-?'[^']*'|--(-?[^-])*--)*(>|$)%%g
>> should handle any valid tags and comments. Extending it to handle
>> marked sections, null-end-tags, and any other SGML oddities one
>> could think of is left as an exercise for the reader.
Ren> Doesn't handle dashes embedded within comments:
Ren> <!-- like -- this -->
Ren> That is legal HTML, isn't it?
Yes, but you're still within a comment. :)
That is,
hello <!-- blah -- blah --> there <!-- blah -- blah --> world
should render as "hello world" in a compliant browser. If it
renders as "hello there world" in your browser, please complain
to your browser manufacturer for providing a substandard comment
parsing logic.
That's because "--"'s are always *paired*. If > appears inside a
pair, it's supposed to be ignored. So says the spec.
--
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: 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.
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 1424
***************************************