[17679] in Perl-Users-Digest
Perl-Users Digest, Issue: 5099 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Dec 13 06:10:29 2000
Date: Wed, 13 Dec 2000 03:10:11 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <976705811-v9-i5099@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Wed, 13 Dec 2000 Volume: 9 Number: 5099
Today's topics:
Re: Removing leading spaces <xzrgpnys@yvtugubhfrovm.pbz>
TMTOWTDI - which way is better? (Philip Lees)
To Blob or not To Blob <barnel@ottawa.com>
Re: To Blob or not To Blob (Logan Shaw)
Tutorial for DBI module and MySQL <mark-lists@webstylists.com>
Re: unicode question (Mihai N.)
Re: Use PERL or Java? Which is faster? <wiz@hogwarts.edu>
Re: Use PERL or Java? Which is faster? <noselasd@frisurf.no>
using s// on *()[]+ in perl regex <qhsand@ehpt.com>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 13 Dec 2000 08:21:27 GMT
From: kevin metcalf <xzrgpnys@yvtugubhfrovm.pbz>
Subject: Re: Removing leading spaces
Message-Id: <3A373216.50A676AE@yvtugubhfrovm.pbz>
Martien Verbruggen wrote:
>
> On 05 Dec 2000 23:11:16 GMT,
> kevin metcalf <xzrgpnys@yvtugubhfrovm.pbz> wrote:
> > Jonathan MILLEY wrote:
> >>
> >> I'm trying to find an effective way to trim leading spaces from
> >> a string.
> >
> > You mean other then the perl manual/faq/cpan perscribed way:
> > $the_variable =~ s/^\s*//;
> > of doing it?
>
> The FAQ actually uses a + instead of a *, because it'll be slightly
> faster.
Thanks honey. Oh, sorry. I thought for a moment I was talking to my
wife. ;)
--
Kevin Metcalf
(Carbon Ocelot)
email: xzrgpnys@yvtugubhfrovm.pbz
Huh? http://www.flactem.com/utils/rot13.html
------------------------------
Date: Wed, 13 Dec 2000 08:45:09 GMT
From: pjlees@ics.forthcomingevents.gr (Philip Lees)
Subject: TMTOWTDI - which way is better?
Message-Id: <3a3730ee.65551958@news.grnet.gr>
Hi. I'm writing an array to an html file and, along the way,
substituting a string for a pattern. If the pattern isn't found the
string gets written right before the </body> tag. Both the following
methods work, but for some reason I feel this nagging dissatisfaction
with both of them.
my $done;
foreach( @old_html ){
$done = $done || s/\*$link_fields[0]\*(?!<\/p>$)/$include_string/i;
unless ( $done ){ print FH "$include_string\n" if /^<\/body>\n$/i };
print FH;
}
foreach( @old_html ){
undef $include_string if
s/\*$link_fields[0]\*(?!<\/p>$)/$include_string/i;
print FH "$include_string\n" if /^<\/body>\n$/i && defined
$include_string;
print FH;
}
To this gradually maturing Perl apprentice the first looks better,
because the regex is never evaluated again after the match is found.
Any comments? suggestions?
Phil
--
Philip Lees
ICS-FORTH, Heraklion, Crete, Greece
Ignore coming events if you wish to send me e-mail
'The aim of high technology should be to simplify, not complicate' - Hans Christian von Baeyer
------------------------------
Date: Wed, 13 Dec 2000 07:11:23 GMT
From: Barnel <barnel@ottawa.com>
Subject: To Blob or not To Blob
Message-Id: <3A3720DB.E58C69C0@ottawa.com>
Can anyone here tell me the pros and cons of storing Blobs in a database
for this type of web application.
The application will allow users to upload jpegs and mp3 files and
store them in a database where these files can later be retrieved from a
webpage.
So I'm thinking: users upload his/her file and store it in the database
as a Blob
Since this users will view and listen to these files from a web page
would it not be simpler if I stored the uploaded file on the file system
and simply put in the database the location of the files which I can
later insert into a web page.
Do you see my dilemma here or is there something I'm overlooking?
------------------------------
Date: 13 Dec 2000 02:32:49 -0600
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: To Blob or not To Blob
Message-Id: <917c7h$sn5$1@boomer.cs.utexas.edu>
In article <3A3720DB.E58C69C0@ottawa.com>, Barnel <barnel@ottawa.com> wrote:
>Can anyone here tell me the pros and cons of storing Blobs in a database
>for this type of web application.
>
>The application will allow users to upload jpegs and mp3 files and
>store them in a database where these files can later be retrieved from a
>webpage.
For one thing, when working with BLOB and other large types, you need
to be a bit careful on the client side of the database. When using
DBI in Perl, you need to set LongReadLen or you may have problems
("perldoc DBI" for more info on that). You also need to use
placeholders to do the insert rather than making a huge query, but
that's kind of common sense since such a query would have quoting
problems if you didn't.
Storing everything in the database will make things cleaner in a
certain sense. You can control access to them in the same ways you can
control access to other data in the database, i.e. the web user can
only get at it through running a script, which might require checking a
session key against the database or something. You can expire and
clean up old data with a simple SQL statement.
Storing everything in the database will also allow you to have more
than one front-end web server without having to worry about duplicating
those zillions of little files. It will also free you from other file
management issues, like if the web user wants to store a filename that
contains some characters you'd really rather not have in a filename on
the actual filesystem. (These will be harmless if they are just in a
field in the database.)
On the other hand, there can be performance problems. What if someone
stores a 100 MB file? If this is in the database as one big BLOB, you
instantly run into some potential problems. The first is the question
of how well your database deals with large numbers of 100 MB BLOBs.
The second is the fact that your Perl script is going to end up reading
the whole 100 MB BLOB into RAM before sending to the remote system. If
you have 50 such scripts running at once, then suddenly you need 5 GB
of RAM just to send out some files which really aren't that big. In
fact, they may even be 50 copies of the *same* file, but unlike when
using the filesystem cache, there will have to be separate storage for
each one since you've made a copy.
You can probably mitigate both of these size problems by storing
the file in the database in chunks of a fixed size, so that if you
want to store 27 KB and you have 8 KB chunks, you might store a single
file like this:
filenum chunknum contents
0 0 (the first 8192 bytes of data)
0 1 (the next 8192 bytes of data)
0 2 (the third 8192 bytes of data)
0 3 (the last 3072 bytes of data)
In this case, you can still get the data out easily enough by doing an
SQL query like this:
select contents from filecontents where filenum=0 order by chunknum
So really, that performance problem can be solved, and in a way that
makes the work of accessing the data only marginally more difficult.
The one other performance issue is that, if the files are in the
database, then every time a user wants to retrieve such a file, there
will have to be a Perl script running for the whole time they are
retrieving it. Perl isn't a terrible resource waster, but then again
http servers are carefully optimized so that serving plain files of
disk is going to be a lot more efficient. It's not as terrible as
starting a script for each on of a bunch of small hits, though -- at
least this Perl scripts will be long-lived, so the start-up penalty
will not occur too often.
In the end, it probably will come down to a practical decision. Is
your database machine big enough to handle all that data? Do you
(potentially) need multiple front-end http servers to go against the
same set of data? Can the front-end http servers handle little bit of
extra load require by running a script? If so, then the database
solution may be the way to go.
Personally, if I were having to make such a decision, I'd just resign
myself to the fact that this is a complex question to answer, and
perhaps only experience will give you the right answer. So, I'd hedge
my bets and make all access to such files happen through some sort of
class that abstracts away the question. That way, I'd be free to
change it later if necessary without recoding unrelated stuff.
- Logan
------------------------------
Date: Tue, 12 Dec 2000 22:40:39 -0800
From: Mark Thompson <mark-lists@webstylists.com>
Subject: Tutorial for DBI module and MySQL
Message-Id: <gc6e3tor3um3gr0kgcr6t16lc25rmctp26@4ax.com>
Hi,
I found the documentatino for using DBI with MySQL but I was wondering
if there was a good tutorial available on using MySQL with Perl.
Thanks,
Mark
------------------------------
Date: 13 Dec 2000 06:36:54 GMT
From: nmihai_2000@yahoo.com (Mihai N.)
Subject: Re: unicode question
Message-Id: <9008E7F49MihaiN@207.172.3.46>
>I'm trying to read and write a utf8 unicode file.
>For example if I open my file with Notepad and
>try to "Save As" the encoding is Unicode.
Only if you are on Windows 2000.
>I want
>to read this file, add some strings, and write
>another file also in unicode, i.e. if I read
>this file with Notepad the encoding should be unicode.
>By unicode file I mean a file in utf8 encoding.
The file saved by notepad is utf16, not utf8.
I will do some tests and I will write again.
Mihai
------------------------------
Date: Tue, 12 Dec 2000 15:23:10 +0100
From: "BarryNL" <wiz@hogwarts.edu>
Subject: Re: Use PERL or Java? Which is faster?
Message-Id: <917d9m$5cq$4@nereid.worldonline.nl>
"Sunil Matta" <smatta@acm.org> wrote in message
news:90lvji$jv9$1@nnrp1.deja.com...
> No comparison. Perl is blindingly fast. Java is slow.
Er, don't you have that the wrong way round. If you think Java is slow I
suggest looking at something like the Java ZX Spectrum emulator which runs
about 4x the speed of the real thing on a Pentium III.
------------------------------
Date: Wed, 13 Dec 2000 10:45:34 +0100
From: "Nils O. Selåsdal" <noselasd@frisurf.no>
Subject: Re: Use PERL or Java? Which is faster?
Message-Id: <GyHZ5.244$Ee.1459@news1.oke.nextra.no>
Just remember:
In the business world, the speed of your coding is often more important
than the spped of the running program...
"Ray Pendergraph" <raypendergraph@my-deja.com> wrote in message > Before you
buy.
------------------------------
Date: Tue, 12 Dec 2000 05:10:50 -0500
From: Andreas Burmester HG/EHS/FD <qhsand@ehpt.com>
Subject: using s// on *()[]+ in perl regex
Message-Id: <0CE269F4A29AD211A7A80060943F425138CDBC@EXCHANGESA>
This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.
------_=_NextPart_000_01C06423.E272E56C
Content-Type: text/plain;
charset="iso-8859-1"
------_=_NextPart_000_01C06423.E272E56C
Content-Type: message/rfc822;
name="Untitled Attachment"
Content-Disposition: attachment;
filename="Untitled Attachment"
Path: Raleigh.MartinMariettaMaterials.com!interpath.net!nntp.news.xara.net!xara.net!gxn.net!news.gradwell.net!news-feed.riddles.org.uk!skynet.be!news.algonet.se!newsfeed1.telenordia.se!algonet!uab.ericsson.se!erix.ericsson.se!newstoo.ericsson.se!not-for-mail
NNTP-Posting-Host: vkhp34.ericsson.se
Newsgroups: comp.lang.perl
From: Andreas Burmester HG/EHS/FD <qhsand@ehpt.com>
Subject: using s// on *()[]+ in perl regex
Message-ID: <3A35F576.861BC21B@ehpt.com>
Date: Tue, 12 Dec 2000 04:52:55 -0500
MIME-Version: 1.0
Lines: 12
X-Newsreader: Microsoft (R) Exchange Internet News Service Version 5.5.2650.12
Organization: ericsson
Content-Type: text/plain
Hello,
Im writing a script that convert a SGML DTD to another.
Im using s// alot to change tags, like this
From <command>This is a command</command>
To <input>This is a command</input>
To do this im using s/<command>(.*)<\/command>/<input>$1<\/input>/; ,
but if there is a * in $1 i get a perl regex error.
Is there any way to get perl to "see" all chars in the reqex as "real"
chars and not as operators?
I have read the regex documention a few times but i cant find anything
there, please help.
Best Regards
Andreas Burmester
------_=_NextPart_000_01C06423.E272E56C
Content-Type: message/rfc822;
name="Untitled Attachment"
Content-Disposition: attachment;
filename="Untitled Attachment"
Path: MMMS.MartinMariettaMaterials.com!interpath.net!nntp.news.xara.net!xara.net!gxn.net!news.gradwell.net!news-feed.riddles.org.uk!skynet.be!news.algonet.se!newsfeed1.telenordia.se!algonet!uab.ericsson.se!erix.ericsson.se!newstoo.ericsson.se!not-for-mail
NNTP-Posting-Host: vkhp34.ericsson.se
Newsgroups: comp.lang.perl.misc
From: Andreas Burmester HG/EHS/FD <qhsand@ehpt.com>
Subject: using s// on *()[]+ in perl regex
Message-ID: <F2BA22F7815BD311B11800805FEF528837A9CC@mmmsnt.martinmarietta.com>
Supersedes: <3A35F9A9.767B24A8@ehpt.com>
Date: Tue, 12 Dec 2000 05:10:50 -0500
MIME-Version: 1.0
Lines: 51
X-Newsreader: Microsoft (R) Exchange Internet News Service Version 5.5.2650.12
Organization: ericsson
Content-Type: message/rfc822;
name="Untitled Attachment"
Content-Disposition: attachment;
filename="Untitled Attachment"
Path: Raleigh.MartinMariettaMaterials.com!interpath.net!nntp.news.xara.net!xara.net!gxn.net!news.gradwell.net!news-feed.riddles.org.uk!skynet.be!news.algonet.se!newsfeed1.telenordia.se!algonet!uab.ericsson.se!erix.ericsson.se!newstoo.ericsson.se!not-for-mail
NNTP-Posting-Host: vkhp34.ericsson.se
Newsgroups: comp.lang.perl
From: Andreas Burmester HG/EHS/FD <qhsand@ehpt.com>
Subject: using s// on *()[]+ in perl regex
Message-ID: <3A35F576.861BC21B@ehpt.com>
Date: Tue, 12 Dec 2000 04:52:55 -0500
MIME-Version: 1.0
Lines: 12
X-Newsreader: Microsoft (R) Exchange Internet News Service Version 5.5.2650.12
Organization: ericsson
Content-Type: text/plain
Hello,
Im writing a script that convert a SGML DTD to another.
Im using s// alot to change tags, like this
From <command>This is a command</command>
To <input>This is a command</input>
To do this im using s/<command>(.*)<\/command>/<input>$1<\/input>/; ,
but if there is a * in $1 i get a perl regex error.
Is there any way to get perl to "see" all chars in the reqex as "real"
chars and not as operators?
I have read the regex documention a few times but i cant find anything
there, please help.
Best Regards
Andreas Burmester
------_=_NextPart_000_01C06423.E272E56C
Content-Type: message/rfc822;
name="Untitled Attachment"
Content-Disposition: attachment;
filename="Untitled Attachment"
Path: REDLAND.MartinMariettaMaterials.com!interpath.net!nntp.news.xara.net!xara.net!gxn.net!news.gradwell.net!news-feed.riddles.org.uk!skynet.be!news.algonet.se!newsfeed1.telenordia.se!algonet!uab.ericsson.se!erix.ericsson.se!newstoo.ericsson.se!not-for-mail
NNTP-Posting-Host: vkhp34.ericsson.se
Newsgroups: comp.lang.perl.misc
From: Andreas Burmester HG/EHS/FD <qhsand@ehpt.com>
Subject: using s// on *()[]+ in perl regex
Message-ID: <0CE269F4A29AD211A7A80060943F425138B6AD@EXCHANGESA>
Supersedes: <3A35F9A9.767B24A8@ehpt.com>
Date: Tue, 12 Dec 2000 05:10:50 -0500
MIME-Version: 1.0
Lines: 51
X-Newsreader: Microsoft (R) Exchange Internet News Service Version 5.5.2650.12
Organization: ericsson
Content-Type: message/rfc822;
name="Untitled Attachment"
Content-Disposition: attachment;
filename="Untitled Attachment"
Path: Raleigh.MartinMariettaMaterials.com!interpath.net!nntp.news.xara.net!xara.net!gxn.net!news.gradwell.net!news-feed.riddles.org.uk!skynet.be!news.algonet.se!newsfeed1.telenordia.se!algonet!uab.ericsson.se!erix.ericsson.se!newstoo.ericsson.se!not-for-mail
NNTP-Posting-Host: vkhp34.ericsson.se
Newsgroups: comp.lang.perl
From: Andreas Burmester HG/EHS/FD <qhsand@ehpt.com>
Subject: using s// on *()[]+ in perl regex
Message-ID: <3A35F576.861BC21B@ehpt.com>
Date: Tue, 12 Dec 2000 04:52:55 -0500
MIME-Version: 1.0
Lines: 12
X-Newsreader: Microsoft (R) Exchange Internet News Service Version 5.5.2650.12
Organization: ericsson
Content-Type: text/plain
Hello,
Im writing a script that convert a SGML DTD to another.
Im using s// alot to change tags, like this
From <command>This is a command</command>
To <input>This is a command</input>
To do this im using s/<command>(.*)<\/command>/<input>$1<\/input>/; ,
but if there is a * in $1 i get a perl regex error.
Is there any way to get perl to "see" all chars in the reqex as "real"
chars and not as operators?
I have read the regex documention a few times but i cant find anything
there, please help.
Best Regards
Andreas Burmester
------_=_NextPart_000_01C06423.E272E56C--
------------------------------
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 5099
**************************************