[17248] in Perl-Users-Digest
Perl-Users Digest, Issue: 4670 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Oct 20 00:05:35 2000
Date: Thu, 19 Oct 2000 21: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)
Message-Id: <972014709-v9-i4670@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Thu, 19 Oct 2000 Volume: 9 Number: 4670
Today's topics:
Re: Converting tabular data to records <anders@wall.alweb.dk>
Re: Converting tabular data to records <skip@northend.com>
Re: Converting tabular data to records <jeff@vpservices.com>
Re: Converting tabular data to records <anders@wall.alweb.dk>
Re: Diagnosing memory hoggishness (Ilya Zakharevich)
Re: Diagnosing memory hoggishness (Martien Verbruggen)
Re: Download via HTTPS? (Martien Verbruggen)
Re: finding mode and median of an array of numbers <james@NOSPAM.demon.co.uk>
Re: finding mode and median of an array of numbers <godzilla@stomp.stomp.tokyo>
Re: finding mode and median of an array of numbers <james@NOSPAM.demon.co.uk>
Re: finding mode and median of an array of numbers <godzilla@stomp.stomp.tokyo>
Help please with script development... (Oawgspresident)
Re: Help please with script development... <godzilla@stomp.stomp.tokyo>
Re: Help please with script development... (Chris Fedde)
Re: how do i find file size? (Martien Verbruggen)
How to turn '<br><br>' or '<br><br><br>' into '<br>' ? lynton@iname.com
Re: How to turn '<br><br>' or '<br><br><br>' into '<br> <elephant@squirrelgroup.com>
Re: How to turn '<br><br>' or '<br><br><br>' into '<br> <james@NOSPAM.demon.co.uk>
Re: How to turn '<br><br>' or '<br><br><br>' into '<br> (Martien Verbruggen)
Re: How to use .pl csript on IIS to send mail to NT Exc (Martin Vorlaender)
Re: manipulating data files <david.obrien@ssmb.com.au>
Newb Question: path variable setting for running Perl f <livewire@enetis.net>
search deja.com 100 times faster with this newsmf@bigfoot.com
Re: Strange memory reading under Win32 <anders@wall.alweb.dk>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 20 Oct 2000 03:13:16 +0200
From: Anders Lund <anders@wall.alweb.dk>
Subject: Re: Converting tabular data to records
Message-Id: <u%MH5.8118$Tq1.287501@news010.worldonline.dk>
Skip Lombardi wrote:
> I have a really ugly data set, and I can get it into a form that looks
> something like this:
>
> Skill 1
> Unspecified
> 16 Oct 2000
> 04 Nov 2000
> 1
> 0.75
> Absolute
> P
> 0.02
>
>
> Now, the task is getting this data into a record on a single line. Does
> anyone have any suggestions?
>
> Best regards,
> Skip Lombardi
>
#!/usr/bin/perl -w
use strict;
use vars qw/@cols $line/;
chomp, push @cols, $_ while (<DATA>);
$line = join "\t", @cols;
print $line, "\n";
__DATA__
Skill 1
Unspecified
16 Oct 2000
04 Nov 2000
1
0.75
Absolute
P
0.02
__END__
=head1 output
Skill 1 Unspecified 16 Oct 2000 04 Nov 2000 1 0.75
Absolute P 0.02
(line above broken for usenet)
--
[ the word wall - and the trailing dot - in my email address
is my _fire_wall - protecting me from the criminals abusing usenet]
------------------------------
Date: Thu, 19 Oct 2000 21:05:09 -0400
From: Skip Lombardi <skip@northend.com>
Subject: Re: Converting tabular data to records
Message-Id: <39EF9A45.37F44A84@northend.com>
Thank you. You're right, I didn't provide enough information. Yes, all new
records will start with the word Skill with the S in upper case. Once I get
the data into record--that is, line by line--format, I plan to write the
resulting file into a .csv format.
There will never be a blank field. The data will never be separated by a
blank line. There will always be nine fields in the data set. The placement
of the fields will never vary.
Jeff Zucker wrote:
> Skip Lombardi wrote:
> >
> > I have a really ugly data set, and I can get it into a form that looks
> > something like this:
> >
> > Skill 1
> > Unspecified
> > 16 Oct 2000
> > 04 Nov 2000
> > 1
> > 0.75
> > Absolute
> > P
> > 0.02
> >
> > Now, the task is getting this data into a record on a single line. Does
> > anyone have any suggestions?
>
> Giving a single example without explaining what about your data is
> consistent between that and other examples is pretty unhelpful. What
> separates that record from the next record (a blank line?) Do all
> records start with the word "Skill" capitalized and followed by a
> number? Is it possible that individual fields within the record also
> start with the word Skill capitalized and followed by a number? Are
> there always exactly 9 lines in a record? Are fields within the record
> ever blank, and if so, how are they currently stored? What format do
> you want the one-line record stored as (fixed width? CSV? tab
> delimited?)
>
> Without knowing the answers to those questions, there's really not much
> way to answer you. It may be there is a fairly simple solution to your
> question but there's no way to know with what you've provided so far.
> Send more.
>
> --
> Jeff
------------------------------
Date: Thu, 19 Oct 2000 18:44:57 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: Converting tabular data to records
Message-Id: <39EFA399.7FA0CA0@vpservices.com>
Skip Lombardi wrote:
>
> Thank you. You're right, I didn't provide enough information. Yes, all new
> records will start with the word Skill with the S in upper case. Once I get
> the data into record--that is, line by line--format, I plan to write the
> resulting file into a .csv format.
>
> There will never be a blank field. The data will never be separated by a
> blank line. There will always be nine fields in the data set. The placement
> of the fields will never vary.
In that case, a slight variation on Anders' solution will work and will
put it into CSV format at the same time (but see below for a caveat on
CSV):
#!/usr/local/bin/perl -w
use strict;
my @cols;
while(<DATA>){
chomp;
push @cols, $_;
if ($. % 9 == 0) {
print join(',',@cols), "\n";
@cols = ();
}
}
__END__
Skill 1
Unspecified
16 Oct 2000
04 Nov 2000
1
0.75
Absolute
P
0.02
Skill 2
Blargaling
17 Oct 2000
05 Nov 2000
2
2.75
Relative
S
0.03
One thing you didn't specify is whether any of the data can contain
commas or quotation marks. If it does, then turning it into CSV is
slightly more complex, but using Text::CSV_XS, you'd only need to add
three lines to the script I show above. Write back if that's the case
and you can't figure out how to use Text::CSV_XS to do it. BTW, I
assume you know that once you have it in CSV format, you can use
Text::CSV_XS to parse it, or if you will be doing database like things
with it, you can use DBI with either DBD::CSV or DBD::RAM, both of which
will treat the CSV file like a SQL accessible database as well as save
you steps with various things like file locking, etc.
--
Jeff
------------------------------
Date: Fri, 20 Oct 2000 03:57:23 +0200
From: Anders Lund <anders@wall.alweb.dk>
Subject: Re: Converting tabular data to records
Message-Id: <QENH5.8122$Tq1.288060@news010.worldonline.dk>
Skip Lombardi wrote:
> Thank you. You're right, I didn't provide enough information. Yes, all
> new
> records will start with the word Skill with the S in upper case. Once I
> get the data into record--that is, line by line--format, I plan to write
> the resulting file into a .csv format.
>
> There will never be a blank field. The data will never be separated by a
> blank line. There will always be nine fields in the data set. The
> placement of the fields will never vary.
>
> Jeff Zucker wrote:
>
> > Skip Lombardi wrote:
> > > .....
in that case:
open FILE, $weirddatafile or die "Couldn't access weird data: $!\n";
# storage
open CSVDATA, ">>$csvfile" or \
die "Couldn't open $csvfile for appending: $!\n";
my @rec # temporary array while creating data structure
while (<FILE>)
print CSVDATA join ("\t", @rec), @rec = () unless ($.%9 or !$.);
chomp; # get rid of newline [sequence]
push @rec, $_;
}
close CSVDATA or die "Bad luck closing $csvdata: $!\n";
close FILE or die "Sticky stuff that data: $!\n";
__END__
You could take a look at DBI and DBD::CSV if the database gets big, or
your'e going to work a lot on that.
-anders
--
[ the word wall - and the trailing dot - in my email address
is my _fire_wall - protecting me from the criminals abusing usenet]
------------------------------
Date: 20 Oct 2000 01:56:54 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: Diagnosing memory hoggishness
Message-Id: <8so8p6$67b$1@charm.magnus.acs.ohio-state.edu>
[A complimentary Cc of this posting was sent to Andrew J. Perrin
<aperrin@demog.berkeley.edu>],
who wrote in article <u66mocqwt.fsf@demog.berkeley.edu>:
> Does anyone have a clever idea of how to write the script's footprint
> to a file on a regular basis, and even potentially how to map what
> variables are taking what amounts of RAM at each time?
I think mstats() writes to STDERR. Lemme check... It goes to C's
Perl_error_log... I do not know whether redirection of STDERR will
help, but most probably it would...
Until "the great lobotomy" documentation of mstats() was in perldebug.
It is probably a week already since the bleeding edge perl allows you
to access these data from Perl directly...
Ilya
------------------------------
Date: Fri, 20 Oct 2000 13:26:13 +1100
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: Diagnosing memory hoggishness
Message-Id: <slrn8uvba5.fji.mgjv@martien.heliotrope.home>
On 19 Oct 2000 20:11:46 -0400,
Andrew J. Perrin <aperrin@demog.berkeley.edu> wrote:
> I know there are significant inefficiencies in the way my package uses
> memory, but many of them have real purposes. What I'd like is some
> way to *systematically* note where in the script there are big jumps
> in memory usage. Since these scripts can run for hours or even days,
Perl doesn't really have any notion of memory usage. I suspect because
the system calls to get at that information are always quite unportable.
You could try to do something with syscall, or write an XS module, but
what I normally do is just call out to ps
my $vsz = (`/bin/ps -p $$ -o vsz`)[1];
$vsz =~ tr/ \n//d;
Martien
--
Martien Verbruggen |
Interactive Media Division | If at first you don't succeed, try
Commercial Dynamics Pty. Ltd. | again. Then quit; there's no use
NSW, Australia | being a damn fool about it.
------------------------------
Date: Fri, 20 Oct 2000 13:29:33 +1100
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: Download via HTTPS?
Message-Id: <slrn8uvbgd.fji.mgjv@martien.heliotrope.home>
On Fri, 20 Oct 2000 02:15:59 +0200,
Anders Lund <anders@wall.alweb.dk> wrote:
> rathmore@tierceron.com wrote:
>
> > Does anyone know of a module that allows you to download a file from an
> > https server? I searched CPAN but didn't have much luck finding what I
> > think I'm after...
>
> LWP
> Libwww-perl is a collection of Perl modules which provides
> a simple and consistent application programming interface
> (API) to the World-Wide Web. The main focus of the
> library is to provide classes and functions that allow you
> to write WWW clients, thus libwww-perl is a WWW client
> library. The library also contain modules that are of more
> general use.
>
> (from the LWP documentation)
I just want to add that if you want to use SLL (HTTPS), that you need to
do some more work. From lwpcook:
# perldoc lwpcook
[snip]
HTTPS
URLs with https scheme are accessed in exactly the same
way as with http scheme, provided that an SSL interface
module for LWP has been properly installed (see the
README.SSL file found in the libwww-perl distribution for
more details). If no SSL interface is installed for LWP
to use, then you will get "501 Protocol scheme 'https' is
not supported" errors when accessing such URLs.
[snip]
and from README.SSL:
Encryption support is obtained through the use of Crypt::SSLeay or
IO::Socket::SSL, which can both be found from CPAN. While libwww-perl
has "plug-and-play" support for both of these modules (as of v5.45),
the recommended module to use is Crypt::SSLeay. In addition to
bringing SSL support to the LWP package, IO::Socket::SSL can be used
as an object oriented interface to SSL encrypted network sockets.
Martien
--
Martien Verbruggen |
Interactive Media Division | The world is complex; sendmail.cf
Commercial Dynamics Pty. Ltd. | reflects this.
NSW, Australia |
------------------------------
Date: Fri, 20 Oct 2000 02:26:19 +0100
From: James Taylor <james@NOSPAM.demon.co.uk>
Subject: Re: finding mode and median of an array of numbers
Message-Id: <ant200119199fNdQ@oakseed.demon.co.uk>
In article <39EF92B0.EA7D4CD9@stomp.stomp.tokyo>,
Godzilla! wrote:
>
> Mode is the most frequently occurring number
> within a number set. Mode requires a minimum
> of two same numbers. If Mode contains sets
> of equal amounts of multiple numbers, Mode is
> a multiplicity number set.
>
> Median is the middle or center number for an
> odd numbered number set. Median is the average
> of the two intermost or two middle numbers for
> an even numbered number set.
Wow, and I was just wondering what the official
mathematical definitions of "mode" and "median"
were. Interesting. Where did you get these
definitions?
Can you suggest a book or preferably a web site
where I might read up on these definitions?
Thanks.
PS. Oh look, by typing my reply under your text
I've subconsciously adopted this narrow column
approach. Spooky...
--
James Taylor <james (at) oakseed demon co uk>
PGP key available ID: 3FBE1BF9
Fingerprint: F19D803624ED6FE8 370045159F66FD02
------------------------------
Date: Thu, 19 Oct 2000 19:27:32 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: finding mode and median of an array of numbers
Message-Id: <39EFAD94.91D7BC32@stomp.stomp.tokyo>
James Taylor wrote:
> Godzilla! wrote:
> Wow, and I was just wondering what the official
> mathematical definitions of "mode" and "median"
> were. Interesting. Where did you get these
> definitions?
Alright, I'll level with you boys, this one time.
I did not 'get' those definitions anywhere. I made
them up. My entire previous article is 100% pure
mule manure, just as is yours.
Godzilla!
------------------------------
Date: Fri, 20 Oct 2000 03:33:25 +0100
From: James Taylor <james@NOSPAM.demon.co.uk>
Subject: Re: finding mode and median of an array of numbers
Message-Id: <ant200225566fNdQ@oakseed.demon.co.uk>
In article <39EFAD94.91D7BC32@stomp.stomp.tokyo>, Godzilla!
<URL:mailto:godzilla@stomp.stomp.tokyo> wrote:
>
> James Taylor wrote:
> > Wow, and I was just wondering what the official
> > mathematical definitions of "mode" and "median"
> > were. Interesting. Where did you get these
> > definitions?
>
> Alright, I'll level with you boys, this one time.
> I did not 'get' those definitions anywhere. I made
> them up. My entire previous article is 100% pure
> mule manure, just as is yours.
Ha! Excellent wind up!
I'm fairly new around here so I'd like to ask:
Do you often write articles of that nature just
to wind people up, or are you mostly serious?
--
James Taylor <james (at) oakseed demon co uk>
PGP key available ID: 3FBE1BF9
Fingerprint: F19D803624ED6FE8 370045159F66FD02
------------------------------
Date: Thu, 19 Oct 2000 19:51:50 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: finding mode and median of an array of numbers
Message-Id: <39EFB346.6E9EE71A@stomp.stomp.tokyo>
James Taylor wrote:
> Godzilla! wrote:
> > James Taylor wrote:
> > > Wow, and I was just wondering what the official
> > > mathematical definitions of "mode" and "median"
> > > were. Interesting. Where did you get these
> > > definitions?
> > Alright, I'll level with you boys, this one time.
> > I did not 'get' those definitions anywhere. I made
> > them up. My entire previous article is 100% pure
> > mule manure, just as is yours.
> Ha! Excellent wind up!
Boys do remind me of wind up toys. Wind 'em
up, let 'em go, they march around in circles
thumping their chests much like the Pink Bunny
thumps her drum. Difference is, the Pink Bunny
lasts and lasts and lasts...
> I'm fairly new around here
I have tiny biting blue monkeys flying out my big butt.
> so I'd like to ask:
Chances are good you will regret asking.
> Do you often write articles of that nature just
> to wind people up,
It is not possible to wind up you Techno-Geeks.
All of you are missing your rubber band.
> or are you mostly serious?
I am mostly ornery.
If you will excuse me, it's dinner time.
Waitress, yoo hoo, waitress, I'll have a
rubber band sandwich and make it snappy.
Godzilla!
------------------------------
Date: 20 Oct 2000 01:51:17 GMT
From: oawgspresident@cs.com (Oawgspresident)
Subject: Help please with script development...
Message-Id: <20001019215117.14929.00000285@ng-fk1.news.cs.com>
Hi, my name is Matt and I've created the layout of a
web-based/interactive/graphic design/strategy game; however, I don't know
enough about HTML/Perl/CGI/Java/Access (or other database applications) to to
actively have it up and running on the Internet. I have taken online tutorials
which only seem to speak to those who alreay understand computer jargon. I am
asking for help. I am asking for more than one person to help at a time. This
is a huge project in my book and will entertain the targeted audience. Because
the game is geared toward non-profit, and free to the user, there is no working
budget, and I don't plan to have one in the future. This is not to say that
your work will not be compensated if you choose to aid me. In the future there
will be a level of finance flowing through the organization to allow monetary
return for your work, but that is in the future after the game is up and
running. To get a better idea about the subject matter for all the various
aforementioned computer science, go to http://oawgs.tripod.com/ to get a better
idea. If you're not familiar with the subject matter, go to http://www.wgi.org
to get a better understanding. And by all means, e-mail me with questions at
oawgspresident@cs.com; I am well versed about it. It is all planned out on
paper and can be easily typed up and transferred via files and e-mail if that
is something you're interested in. Thanks in advace!
Matt Zarzyczka
------------------------------
Date: Thu, 19 Oct 2000 19:31:05 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Help please with script development...
Message-Id: <39EFAE69.80BF2FF1@stomp.stomp.tokyo>
Oawgspresident wrote:
> Hi, my name is Matt
Hello. My name is Godzilla!
I have decided to step on you.
* SQUISH *
Godzilla!
------------------------------
Date: Fri, 20 Oct 2000 02:37:31 GMT
From: cfedde@fedde.littleton.co.us (Chris Fedde)
Subject: Re: Help please with script development...
Message-Id: <LdOH5.111$T3.170573312@news.frii.net>
In article <39EFAE69.80BF2FF1@stomp.stomp.tokyo>,
Godzilla! <godzilla@stomp.stomp.tokyo> wrote:
>Oawgspresident wrote:
>
>> Hi, my name is Matt
>
>Hello. My name is Godzilla!
>I have decided to step on you.
>
>
>* SQUISH *
>
>
>Godzilla!
;\ >
/ ;
; (
< :\
/ ` `.
) `._
/`. `-._
( `~--,.._
)- _.-:._ \
> ,-~~~-<_ \ )
/- \__ \~~\ )
; `~\ ) ) '
/``-( \ ) \'
``~-( \' ,'
`-.;.-.;.-,-.;.-.:.-.;.-.;.-..-.-._._._..-.-.-._--.--`
_.-_.-' \_ `. `'~--._`-..
;-`,-' `-.`._ `-./
`-' `-.`-._
`-.`-.
\_/
http://www.stomptokyo.com/godzillatemple/photos/gvsbambi.txt
--
This space intentionally left blank
------------------------------
Date: Fri, 20 Oct 2000 13:09:47 +1100
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: how do i find file size?
Message-Id: <slrn8uvabb.fji.mgjv@martien.heliotrope.home>
[please, in the future, put your reply _after_ the suitably trimmed
text you reply to. It makes followups easier to read, and is in
accordance with the generally accepted style on this group, and Usenet
as a whole.]
On Thu, 19 Oct 2000 23:39:00 GMT,
EM <me@privacy.net> wrote:
[re-ordered and cut down post]
O
> "Martien Verbruggen" <mgjv@tradingpost.com.au> wrote in message
> news:slrn8uv0oo.fji.mgjv@martien.heliotrope.home...
> > On Thu, 19 Oct 2000 21:34:05 GMT,
> > EM <me@privacy.net> wrote:
> >
> > > also does anyone know any code to download a binary file off a
> > > http server and save it to a file
> >
> > Maybe instead of using get, you should use getstore($url, $filename).
> > That way both problems I mentioned should go away.
>
> Thanks alot!!!
> getstore($url, $filename) works perfectly but
> is there a way i can show in the browser the current status of the
> transfer?
Not that I know of with LWP::Simple. In any case, you won't be able to
show anything in the browser, because this doesn't run in the browser,
unless you mean that your program is the browser?
If you use LWP::UserAgent directly, you can define a callback sub, as
well as a chunk size. If you do so, LWP will call that sub for each
chunk downloaded, and you can decide what to do at that moment. You will
have to take care of everything yourself: Saving of data, updating
counters, etc.
How to display this information in a browser, so that it updates live
I'll leave up to you. You'll have to go to comp.infosystems.www.*
somewhere to find out how to do that sort of stuff over HTTP.
A good starting point could be:
#!/usr/local/bin/perl -w
use strict;
use LWP::UserAgent;
use HTTP::Request;
my $transferred = 0;
my $url = shift or die "Usage: $0 URL [outfile]\n";
my $req = HTTP::Request->new(GET => $url) or die "Cannot request $url";
my $ua = LWP::UserAgent->new();
my $o_file = shift;
if ($o_file)
{
open(OUT, ">$o_file") or die "Cannot open $o_file: $!";
}
else
{
*OUT = *STDOUT;
}
binmode OUT;
my $resp = $ua->request($req, \&callback, 4096);
print STDERR "\n";
sub callback
{
my ($data, $response, $protocol) = @_;
$transferred += length($data);
printf STDERR "\rTransferred: %d bytes", $transferred;
print OUT $data;
}
__END__
Call this as
# ./proggie 'http://www.foo.bar/some_file' > outfile
or
# ./proggie 'http://www.foo.bar/some_file' outfile
Isn't it good that the LWP modules exist? It's now possible to write
little tools like these in less time than it takes to get a coffee.
Oh, note that some of the above might not work on all terminals. It
works for me, but it may not work for you.
Martien
--
Martien Verbruggen |
Interactive Media Division | Little girls, like butterflies, need
Commercial Dynamics Pty. Ltd. | no excuse - Lazarus Long
NSW, Australia |
------------------------------
Date: Fri, 20 Oct 2000 00:56:11 GMT
From: lynton@iname.com
Subject: How to turn '<br><br>' or '<br><br><br>' into '<br>' ?
Message-Id: <8so579$13a$1@nnrp1.deja.com>
How to turn '<br><br>' or '<br><br><br>' into '<br>' ?
s/(<br>)+/<br>/gs; won't work
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Fri, 20 Oct 2000 12:25:34 +1000
From: jason <elephant@squirrelgroup.com>
Subject: Re: How to turn '<br><br>' or '<br><br><br>' into '<br>' ?
Message-Id: <MPG.145a58264869091898982d@localhost>
lynton@iname.com wrote ..
>How to turn '<br><br>' or '<br><br><br>' into '<br>' ?
>
>s/(<br>)+/<br>/gs; won't work
yes it does (although it should be added that both the 'g' and 's'
modifiers are not required
--
jason -- elephant@squirrelgroup.com --
------------------------------
Date: Fri, 20 Oct 2000 02:33:22 +0100
From: James Taylor <james@NOSPAM.demon.co.uk>
Subject: Re: How to turn '<br><br>' or '<br><br><br>' into '<br>' ?
Message-Id: <ant2001226e8fNdQ@oakseed.demon.co.uk>
In article <MPG.145a58264869091898982d@localhost>, jason
<URL:mailto:elephant@squirrelgroup.com> wrote:
> lynton@iname.com wrote ..
> >How to turn '<br><br>' or '<br><br><br>' into '<br>' ?
> >
> >s/(<br>)+/<br>/gs; won't work
>
> yes it does (although it should be added that both the
> 'g' and 's' modifiers are not required
Perhaps he just needs to include the possibility of whitespace
between each <br> tag. He might also wish to cope with
attributes of the <br> tag. For example:
s/(<br[^>]*>\s*)+/<br>/;
--
James Taylor <james (at) oakseed demon co uk>
PGP key available ID: 3FBE1BF9
Fingerprint: F19D803624ED6FE8 370045159F66FD02
------------------------------
Date: Fri, 20 Oct 2000 13:40:50 +1100
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: How to turn '<br><br>' or '<br><br><br>' into '<br>' ?
Message-Id: <slrn8uvc5i.fji.mgjv@martien.heliotrope.home>
On Fri, 20 Oct 2000 00:56:11 GMT,
lynton@iname.com <lynton@iname.com> wrote:
> How to turn '<br><br>' or '<br><br><br>' into '<br>' ?
>
> s/(<br>)+/<br>/gs; won't work
Yes, it will, and so will s/(<br>)+/<br>/g; I don't think the s flag
does what you think it does. In your case it doesn't do anything,
because you don't have a '.' in your RE.
If you're only matching a single sequence, then you don't even need the
/g. But I suspect that your question is more along the line: I've got a
string that contains HTML. I want to replace all sequences of <br> with
a single <br>.
Maybe you need it to be case-insensitive? Add the i flag.
Maybe you want to allow whitespace between the <br>'s?
s/(<br>\s*)+/<br>/ig;
Although this will also eat trailing whitespace. Since that whitespace
should be insignificant in HTML anyway (I believe) that is acceptable.
If it isn't, try
s/(<br>\s*)+(?=<br>)//ig;
or, if you mind capturing stuff when not using it:
s/(?:<br>\s*)+(?=<br>)//ig;
# man perlre
(?:RE) groups but doesn't capture
(?=RE) is a zero-width look-ahead assertion. This means that the RE has
to be there, but doesn't get included in the match.
Martien
--
Martien Verbruggen |
Interactive Media Division | That's not a lie, it's a
Commercial Dynamics Pty. Ltd. | terminological inexactitude.
NSW, Australia |
------------------------------
Date: Fri, 20 Oct 2000 05:07:49 +0200
From: martin@radiogaga.harz.de (Martin Vorlaender)
Subject: Re: How to use .pl csript on IIS to send mail to NT Exchange.
Message-Id: <39efb705.524144494f47414741@radiogaga.harz.de>
James Taylor (james@NOSPAM.demon.co.uk) wrote:
: Tony Curtis <tony_curtis32@yahoo.com> wrote:
: > http://search.cpan.org/, enter "Net::SMTP" and there you are.
:
: Oh! That was easy. I wonder why I couldn't find it in any of
: the lists and categories at http://www.perl.com/CPAN/
It's part of the libnet package.
cu,
Martin
--
One OS to rule them all | Martin Vorlaender | VMS & WNT programmer
One OS to find them | work: mv@pdv-systeme.de
One OS to bring them all | http://www.pdv-systeme.de/users/martinv/
And in the Darkness bind them.| home: martin@radiogaga.harz.de
------------------------------
Date: Fri, 20 Oct 2000 14:05:04 +1000
From: Dave O'Brien <david.obrien@ssmb.com.au>
Subject: Re: manipulating data files
Message-Id: <39EFC470.2882C3C3@ssmb.com.au>
>
> _______
> | |
> | 2.5 |
> |_______|
>
> Godzilla!
<sarcasm>
snappy comeback
</sarcasm>
------------------------------
Date: Thu, 19 Oct 2000 20:39:39 -0700
From: "Wade \"Boomer\" VanderBoom" <livewire@enetis.net>
Subject: Newb Question: path variable setting for running Perl from Dos prompt
Message-Id: <39efb0ae$1@news.enetis.net>
After installing activestate perl, system will run perl scripts through
windows, but chaning to DOS prompt to run the perl script with appropriate
"perl script.plx" it defaults to bad command.
man pages mention something about a "shebang" bat, can anyone explain?
------------------------------
Date: Fri, 20 Oct 2000 01:41:08 GMT
From: newsmf@bigfoot.com
Subject: search deja.com 100 times faster with this
Message-Id: <8so7rk$329$1@nnrp1.deja.com>
When searching Usenet for perl-related messages, try www.qbsearch.com.
Check the "deja.com" box and you can search for "perl AND array" and
get 20 result pages at once.
The best: Choose the "qbView" option and then on the 20-pages result
page click on all message links you want to read and then on
the "hovering" Quickbrowse button in the bottom right to scan all
selected messages combined into a single page. It's superfast.
It's great for quickly viewing an entire thread: I simply click on all
the thread links and then see all the messages combined inside a single
page. It's at www.qbsearch.com.
Great time saver.
Marc.
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Fri, 20 Oct 2000 03:22:32 +0200
From: Anders Lund <anders@wall.alweb.dk>
Subject: Re: Strange memory reading under Win32
Message-Id: <a8NH5.8120$Tq1.287689@news010.worldonline.dk>
Andrew J. Perrin wrote:
> Greetings. Running a script with a very large array (see my previous
> post) under NT4 (activeperl 5.6.0), I've noticed an odd
> behavior. Typically I keep three windows open: a cygwin-bash window
> from which the script was started, another with a tail -f to watch the
> output, and the Windows NT Task Manager to watch memory consumption.
>
> What I've noted is that when I minimize the window from which the perl
> script was started, perl.exe drops to 0 bytes of RAM used in the task
> manager, then slowly climbs back up (in this case, to about 60
> megabytes). This is reproducible - maximizing and minimizing it again
> does the same thing.
>
> Questions:
> - Is this normal? Why?
> - What are the implications for the script's efficiency if it has to
> recopy itself into memory?
>
> Thanks.
>
long live laziness!!
Windows thinks that if you minimize a window, you dont care for the work it
represents...
On memory usage: a query in perlfaq for "memory" dosen't give much, just a
suggestion to try another malloc, needs recompilation I think.
-anders
--
[ the word wall - and the trailing dot - in my email address
is my _fire_wall - protecting me from the criminals abusing usenet]
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 99)
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: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
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 V9 Issue 4670
**************************************