[16462] in Perl-Users-Digest
Perl-Users Digest, Issue: 3874 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Aug 1 18:10:58 2000
Date: Tue, 1 Aug 2000 15:10:27 -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: <965167827-v9-i3874@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Tue, 1 Aug 2000 Volume: 9 Number: 3874
Today's topics:
Re: No more typeglobs in Perl 6 <dan@tuatha.sidhe.org>
numeric storage efficiency <cawlfiel@uiuc.edu>
Re: numeric storage efficiency <iltzu@sci.invalid>
Re: On upgrading Perl... (Greg Bacon)
Perl CGI - files occasionally truncated mikelot@my-deja.com
Re: Perl CGI - files occasionally truncated (Logan Shaw)
Perl Module in C - Question. (Campbell)
Re: Perl Module in C - Question. (Greg Bacon)
Re: Perl Module in C - Question. <billy@arnis-bsl.com>
Re: Perl Module in C - Question. (Abigail)
Re: Perl Module in C - Question. <fortinj@attglobal.net>
Re: Perl Module in C - Question. (Logan Shaw)
Re: Perl Module in C - Question. <iltzu@sci.invalid>
Re: Perl Module in C - Question. (Greg Bacon)
Re: posting in newsgroup using perl script? (Abigail)
Re: posting in newsgroup using perl script? <bart.lateur@skynet.be>
question about tr (T. Postel)
Re: question about tr (Greg Bacon)
Re: question about tr <lr@hpl.hp.com>
References - I just don't get them! <terri143@email.msn.com>
Re: References - I just don't get them! (Greg Bacon)
Re: References - I just don't get them! <lauren_smith13@hotmail.com>
Re: References - I just don't get them! <hyagillot@tesco.net>
Re: regular expression question.... (Craig Berry)
Re: Regular expression <lr@hpl.hp.com>
Re: Regular expression <billy@arnis-bsl.com>
Re: Removing newline chars <godzilla@stomp.stomp.tokyo>
Re: Removing newline chars (Logan Shaw)
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 01 Aug 2000 22:02:32 GMT
From: Dan Sugalski <dan@tuatha.sidhe.org>
Subject: Re: No more typeglobs in Perl 6
Message-Id: <YNHh5.9199$f_5.47807@news1.rdc1.ct.home.com>
Keith Calvert Ivey <kcivey@cpcug.org> wrote:
> As for [3] and [4], how do you think Exporter.pm and English.pm
> work? If you don't know, look inside them. They use typeglobs.
> That said, there's no reason Perl 6 couldn't have a new syntax
> for creating aliases that didn't require typeglobs.
An extension to the *foo{THING} syntax that didn't actually need the *
would do it. A reference to a symbol table entry can essentially act as a
hash with a limited and fixed set of keys.
You still have globs, of a sort, under the hood (well, maybe), but globs
as a visible language feature go away.
Dan
------------------------------
Date: Tue, 01 Aug 2000 13:06:29 -0500
From: Topher Cawlfield <cawlfiel@uiuc.edu>
Subject: numeric storage efficiency
Message-Id: <398711A5.1AB7F1AB@uiuc.edu>
Hi,
I was recently working with a Perl script which seemed to have a memory
leak, and would crash with "Out of memory" after an hour or two. It turned
out that there was no memory leak, and it was only storing arrays of
numbers *very* inefficiently! The appearance of a memory leak was really
just the gradual conversion of strings into floating point representations.
The script first reads in 24 "template" files, each with about 40,000
numbers. It then reads in several thousand more files one at a time,
compares values, and computes statistics. Anyway, after reading the
template files it will have a large data structure which is a hash table of
arrays ($hhe{$chmr}[$n]). The hash table contains 480 elements, and the
arrays all contain almost 1000 scalars. There are two such arrays, so I am
storing in memory about one million numbers, divided into 1000 arrays of
1000 each.
Naively I would think that since the script first reads these numbers in as
text, they would require about 12 bytes per number, so it would take up
12MB of memory. Not so! After reading in these files the Perl interpreter
is consuming 80MB! That's a factor of almost 8 more than I can account
for.
As the program runs, it periodically uses chunks of about 50,000 of these
numbers at a time in a numerical context, so I believe that Perl converts
these values into a double precision representation, 8 bytes per number.
So if anything I would expect the core size of the Perl interpreter to
shrink. But instead of doing that, it actually increases by about 2MB per
chunk, and eventually runs out of memory when it's near completion. So I
thought maybe Perl actually creates a dual representation of each number,
keeping the string representation and creating a FP one. But if that were
the case it would only increase by 8 bytes per number, a mere .5MB!
Somehow it's adding about 50 bytes per number when I access them in a
numerical context.
I "solved" the problem by copying the values into local variables before
doing the math, and indeed the core size held steady at 80MB as the script
ran. But it runs a little slower and leaves me a bit mystified. How can
Perl be using ~150 bytes of storage per number? I'm not using any packages
like BigFloat. Does anyone know exactly what Perl is doing here? (If I
had a choice, I'd have Perl use single precision for all numbers, like any
sane programmer would.)
This is the first time I've posted to this newsgroup and I just want to
take the opportunity to say that I really love Perl! Since learning it in
'96 Perl has been an invaluable tool, and I have written thousands of
scripts, big and small, since. I use it for CGI scripts, all kinds of
accounting/database-type work, text file manipulation, process control, and
everything else that would otherwise be burdensome (except possibly washing
dishes). Perl is always enjoyable and easy to work with, a great language
for getting things done.
- Topher Cawlfield
------------------------------
Date: 1 Aug 2000 18:57:10 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: numeric storage efficiency
Message-Id: <965155745.6096@itz.pp.sci.fi>
In article <398711A5.1AB7F1AB@uiuc.edu>, Topher Cawlfield wrote:
>As the program runs, it periodically uses chunks of about 50,000 of these
>numbers at a time in a numerical context, so I believe that Perl converts
>these values into a double precision representation, 8 bytes per number.
>So if anything I would expect the core size of the Perl interpreter to
>shrink. But instead of doing that, it actually increases by about 2MB per
>chunk, and eventually runs out of memory when it's near completion. So I
Sorry, but I can't duplicate that. It would be extremely helpful if
you could manage to reduce your program to a self-contained example of
less than a dozen or so lines, so that it runs from the command line
and still demonstrates the problem.
If you can, do post it here so that we can cut-and-paste and run it
and see the behavior ourselves. If the problem vanishes in the
process, take a *good* look at the parts you last removed..
Is it possible that you're accidentally trying to modify a value past
the end of the array? Perl will happily extend the array for you if
you do that, which can eat a lot of memory if the indices are large..
--
Ilmari Karonen - http://www.sci.fi/~iltzu/
"The screwdriver *is* the portable method." -- Abigail
Please ignore Godzilla and its pseudonyms - do not feed the troll.
------------------------------
Date: Tue, 01 Aug 2000 19:03:24 GMT
From: gbacon@HiWAAY.net (Greg Bacon)
Subject: Re: On upgrading Perl...
Message-Id: <soe7ns3ddbm18@corp.supernews.com>
In article <39870708.E5433C68@bownemgmt.com>,
Mike Styne <mstyne@bownemgmt.com> wrote:
: Greg Bacon wrote:
:
: > Why? Simply install your perl upgrades in /usr/local.
:
: I was under the impression that installing to /usr/local (while still
: having the distribution's older version at /usr) would cause problems.
: If you're fairly sure it won't, then that's what i'll do. Thanks for the
: help.
If everything is working fine with /usr/bin/perl, then adding a new
perl to /usr/local won't hurt anything. You can test and migrate
all your Perl code to the new version at your own pace. When you
perform future upgrades, you may have to reinstall some modules for
your new version, but, again, you can do that at your own pace as you
migrate any production code to the new version.
Greg
--
A list is only as strong as its weakest link.
-- Knuth
------------------------------
Date: Tue, 01 Aug 2000 20:01:25 GMT
From: mikelot@my-deja.com
Subject: Perl CGI - files occasionally truncated
Message-Id: <8m7aag$c6s$1@nnrp1.deja.com>
I have a Perl CGI which basically updates a flatfile database based on
form input. I'm following the recommended process (from the FAQ) of
creating a new temporary file, writing to that, then doing a rename to
the original file name as the last step.
I'm finding (very infrequently, as in months before a failure) that the
file is not always updated correctly - that it may in fact be left
empty or with only a few records. Is it possible that the perl cgi is
getting killed in the middle of the rename step? What's the best
workaround - a signal handler?
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 1 Aug 2000 16:11:14 -0500
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: Perl CGI - files occasionally truncated
Message-Id: <8m7edi$bnj$1@provolone.cs.utexas.edu>
In article <8m7aag$c6s$1@nnrp1.deja.com>, <mikelot@my-deja.com> wrote:
>I have a Perl CGI which basically updates a flatfile database based on
>form input. I'm following the recommended process (from the FAQ) of
>creating a new temporary file, writing to that, then doing a rename to
>the original file name as the last step.
>
>I'm finding (very infrequently, as in months before a failure) that the
>file is not always updated correctly - that it may in fact be left
>empty or with only a few records. Is it possible that the perl cgi is
>getting killed in the middle of the rename step? What's the best
>workaround - a signal handler?
Are you locking the file? What if two CGIs run at the same time and
try to update the file? In many cases, this kind of a scenario leads
to corruption of flat file databases.
Personally, I'd consider going to a database. MySQL is free and it
will almost definitely serve your needs. Plus, it will probably be
more efficient than loading and re-writing the file every time you make
a small change in it.
- Logan
------------------------------
Date: 01 Aug 2000 19:30:04 GMT
From: cb921@cb921.org (Campbell)
Subject: Perl Module in C - Question.
Message-Id: <slrn8oe99r.ctj.cb921@cb921.org>
Good Day...
I have a simple question, perhaps best answered with a web reference
or manpage? I would greatly appreciate it if someone who knows could
take the time to do so... my most valiant efforts have left me without
a clue.
I have been supplied by the manufacturer of my hardware a set of drivers
and some C header files, defining a load of functions. I would prefer to
use Perl for the actual work here, knowing only the survival basics of C.
I believe that the correct way to achieve this is to create a module,
using C, which allows the Perl script to call functions by a slightly
different name, which will pass the arguments to the 'real' function,
and return any returns to the calling script.
It sounds really simple... but just about the 'only' existing documents
on the web to do with creating modules deal with creating them in perl,
not C.
It could be that my level of experience just needs an upgrade, but that
is what I'm trying to do..... Can anyone here point me?
Thank you,
Campbell
--
It's not that Perl programmers are idiots, it's that
the language rewards idiotic behaviour in a way that
no other tool or language has ever done. - Eric Naggum
------------------------------
Date: Tue, 01 Aug 2000 19:54:07 GMT
From: gbacon@HiWAAY.net (Greg Bacon)
Subject: Re: Perl Module in C - Question.
Message-Id: <soeamvepdbm174@corp.supernews.com>
In article <slrn8oe99r.ctj.cb921@cb921.org>,
Campbell <cb921@voice.co.za> wrote:
: I believe that the correct way to achieve this is to create a module,
: using C, which allows the Perl script to call functions by a slightly
: different name, which will pass the arguments to the 'real' function,
: and return any returns to the calling script.
Consult the perlxstut and perlxs manpages. They describe how to do
what you want.
Greg
--
What was the best thing before sliced bread?
-- George Carlin
------------------------------
Date: Tue, 01 Aug 2000 15:02:34 -0500
From: Ilja Tabachnik <billy@arnis-bsl.com>
Subject: Re: Perl Module in C - Question.
Message-Id: <39872CDA.50D194E2@arnis-bsl.com>
Campbell wrote:
>
> Good Day...
>
> I have a simple question, perhaps best answered with a web reference
> or manpage? I would greatly appreciate it if someone who knows could
> take the time to do so... my most valiant efforts have left me without
> a clue.
>
> I have been supplied by the manufacturer of my hardware a set of drivers
> and some C header files, defining a load of functions. I would prefer to
> use Perl for the actual work here, knowing only the survival basics of C.
>
> I believe that the correct way to achieve this is to create a module,
> using C, which allows the Perl script to call functions by a slightly
> different name, which will pass the arguments to the 'real' function,
> and return any returns to the calling script.
>
> It sounds really simple... but just about the 'only' existing documents
> on the web to do with creating modules deal with creating them in perl,
> not C.
>
IMHO, the most answers are closer than the web:
perldoc perlxs
perldoc perlxstut
perldoc perlguts
Ilja.
------------------------------
Date: 01 Aug 2000 16:25:39 EDT
From: abigail@foad.org (Abigail)
Subject: Re: Perl Module in C - Question.
Message-Id: <slrn8oechf.vcg.abigail@alexandra.foad.org>
Campbell (cb921@cb921.org) wrote on MMDXXVII September MCMXCIII in
<URL:news:slrn8oe99r.ctj.cb921@cb921.org>:
--
--
-- It sounds really simple... but just about the 'only' existing documents
-- on the web to do with creating modules deal with creating them in perl,
-- not C.
What is it with people who think everything is to be found on the web,
and only on the web?
Type 'man perl' and admire the rich list of man pages that comes with
Perl. Right there on your local disk drive. To be enjoyed without the
pains of a web wowser, long delays and migraine causing banner ads.
Abigail
--
BEGIN {$^H {q} = sub {$_ [1] =~ y/S-ZA-IK-O/q-tc-fe-m/d; $_ [1]}; $^H = 0x28100}
print "Just another PYTHON hacker\n";
------------------------------
Date: Tue, 01 Aug 2000 17:04:06 -0400
From: John Fortin <fortinj@attglobal.net>
Subject: Re: Perl Module in C - Question.
Message-Id: <nneeoschbm15pski7lpdcrpdqlo1dcm4uu@4ax.com>
On 01 Aug 2000 16:25:39 EDT, abigail@foad.org (Abigail) wrote:
>Campbell (cb921@cb921.org) wrote on MMDXXVII September MCMXCIII in
><URL:news:slrn8oe99r.ctj.cb921@cb921.org>:
>--
>--
>-- It sounds really simple... but just about the 'only' existing documents
>-- on the web to do with creating modules deal with creating them in perl,
>-- not C.
>
>What is it with people who think everything is to be found on the web,
>and only on the web?
>
>Type 'man perl' and admire the rich list of man pages that comes with
>Perl. Right there on your local disk drive. To be enjoyed without the
>pains of a web wowser, long delays and migraine causing banner ads.
>
hmmm, Activestate perl for windows doesn't seem to have manpages.
A bit 'unix'centric are we??
------------------------------
Date: 1 Aug 2000 16:09:15 -0500
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: Perl Module in C - Question.
Message-Id: <8m7e9r$bmk$1@provolone.cs.utexas.edu>
In article <nneeoschbm15pski7lpdcrpdqlo1dcm4uu@4ax.com>,
John Fortin <fortinj@attglobal.net> wrote:
>hmmm, Activestate perl for windows doesn't seem to have manpages.
>A bit 'unix'centric are we??
It has them. They're just hidden somewhere and called something
different. Somewhere in the install, there's a directory that
contains lots of HTML documentation, and I believe they're in there.
- Logan
------------------------------
Date: 1 Aug 2000 21:49:26 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: Perl Module in C - Question.
Message-Id: <965166460.25924@itz.pp.sci.fi>
In article <8m7e9r$bmk$1@provolone.cs.utexas.edu>, Logan Shaw wrote:
>In article <nneeoschbm15pski7lpdcrpdqlo1dcm4uu@4ax.com>,
>John Fortin <fortinj@attglobal.net> wrote:
>>hmmm, Activestate perl for windows doesn't seem to have manpages.
>>A bit 'unix'centric are we??
>
>It has them. They're just hidden somewhere and called something
s/somewhere/in the Start menu/, IIRC.
--
Ilmari Karonen - http://www.sci.fi/~iltzu/
"The screwdriver *is* the portable method." -- Abigail
Please ignore Godzilla and its pseudonyms - do not feed the troll.
------------------------------
Date: Tue, 01 Aug 2000 22:01:55 GMT
From: gbacon@HiWAAY.net (Greg Bacon)
Subject: Re: Perl Module in C - Question.
Message-Id: <soei6jufdbm31@corp.supernews.com>
In article <nneeoschbm15pski7lpdcrpdqlo1dcm4uu@4ax.com>,
John Fortin <fortinj@attglobal.net> wrote:
: hmmm, Activestate perl for windows doesn't seem to have manpages.
Look again.
Greg
--
The viewing of web pages must not put the reader at risk of epileptic
seizures.
-- Tom Christiansen
------------------------------
Date: 01 Aug 2000 15:18:40 EDT
From: abigail@foad.org (Abigail)
Subject: Re: posting in newsgroup using perl script?
Message-Id: <slrn8oe8k3.vcg.abigail@alexandra.foad.org>
Ron (r.roosjen@koersagent.nl) wrote on MMDXXVII September MCMXCIII in
<URL:news:3986E054.331FDD77@koersagent.nl>:
,,
,, Now running it gives the following error:
,,
,, "sh: 1: Syntax error: newline unexpected "
,,
,, and the program hangs for a while.
,,
,, What can this be?
,,
,,
,, > my @message = split /\n/,<<`EOMESS`;
^ ^ That of course starts up a shell.
Abigail
--
perl5.004 -wMMath::BigInt -e'$^V=Math::BigInt->new(qq]$^F$^W783$[$%9889$^F47]
.qq]$|88768$^W596577669$%$^W5$^F3364$[$^W$^F$|838747$[8889739$%$|$^F673$%$^W]
.qq]98$^F76777$=56]);$^U=substr($]=>$|=>5)*(q.25..($^W=@^V))=>do{print+chr$^V
%$^U;$^V/=$^U}while$^V!=$^W'
------------------------------
Date: Tue, 01 Aug 2000 19:24:59 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: posting in newsgroup using perl script?
Message-Id: <lr8eosg36ijmf9memo0dvnjn1aiq6sklcn@4ax.com>
Abigail wrote:
>,, > my @message = split /\n/,<<`EOMESS`;
> ^ ^ That of course starts up a shell.
Jeezes! JNS, what were you thinking...
--
Bart.
------------------------------
Date: Tue, 01 Aug 2000 19:14:31 GMT
From: T.Postel@ieee.org (T. Postel)
Subject: question about tr
Message-Id: <fkFh5.5854$VoS4.72810829@news.randori.com>
on unix: version 5.004_02
and on win 95: version 5.005_03
I have been using tr to untaint input like this:
$Group =~ tr/A-Za-z0-9 -_//cd;
But I found, and I can't explain why, it doesn't work.
This does work and I've changed to it:
$Group =~ tr/_A-Za-z0-9 -//cd;
I haven't found an explanation why adding an underscore to the end of the searchlist causes the tr
to fail.
Test string: $Group = '>TEST-1 ';
TIA.
--
While my e-mail address is not munged, | T.Postel@ieee.org
I probably won't read anything sent there. |
------------------------------
Date: Tue, 01 Aug 2000 19:52:53 GMT
From: gbacon@HiWAAY.net (Greg Bacon)
Subject: Re: question about tr
Message-Id: <soeakl61dbm159@corp.supernews.com>
In article <fkFh5.5854$VoS4.72810829@news.randori.com>,
T. Postel <T.Postel@ieee.org> wrote:
: I have been using tr to untaint input like this:
tr/// doesn't untaint anything. The perlsec manpage tells you how to
untaint data.
: $Group =~ tr/A-Za-z0-9 -_//cd;
: But I found, and I can't explain why, it doesn't work.
Define "doesn't work". Did you intend to make a range from space to
underscore, or do you want " ", "-", and "_" to be in the searchlist?
If you don't want the - to indicate a range, move it to one end (as
you did in the example that you reported as working) or backwhack it.
Greg
--
Buy land. They've stopped making it.
-- Mark Twain
------------------------------
Date: Tue, 1 Aug 2000 12:44:20 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: question about tr
Message-Id: <MPG.13f0c86a39c7cd6b98ac19@nntp.hpl.hp.com>
In article <fkFh5.5854$VoS4.72810829@news.randori.com> on Tue, 01 Aug
2000 19:14:31 GMT, T. Postel <T.Postel@ieee.org> says...
...
> I have been using tr to untaint input like this:
> $Group =~ tr/A-Za-z0-9 -_//cd;
> But I found, and I can't explain why, it doesn't work.
> This does work and I've changed to it:
> $Group =~ tr/_A-Za-z0-9 -//cd;
> I haven't found an explanation why adding an underscore to the end
> of the searchlist causes the tr
> to fail.
Because it creates a range ' ' to '_', which is a whole lot of
characters! :-)
Moving the '_' to the front puts the '-' at the end, so is loses its
metasemantics.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Tue, 1 Aug 2000 14:45:51 -0500
From: "terri143" <terri143@email.msn.com>
Subject: References - I just don't get them!
Message-Id: <Ov4TjD$#$GA.328@cpmsnbbsa08>
Hi,
Sorry for asking what I know will be a dumb question but I don't have anyone
else to ask. This is driving me up the wall. Let me start by saying that I
learned to use strict and -w from reading this newsgroup. I have been
reading this group for quite a while now and have learned a lot. Thanks for
all the help even when you did not know you where helping me.
I have read docs, two perl books, many post on the subject and looked at a
lot of other people's code trying to understand this. My programming
experience is limited and that may be why I just don't get it.
In a nut shell can some one point me to a good resource or examples of what
references are used for? I know the docs and lots of other places explain
this but I just don't get it. From what I understand references "point" to a
variable but not "really"? I think that I may be using up memory needlessly
because of my improper use of them.
Is there just like a real simple example that someone could give me? One
that maybe I can see easy? I had a hard time understanding scopes and such a
while back. I am betting my money that these two are "close" together.
Look, you can make fun of me or whatever you want to do if you will just
help.
Thanks very much........
------------------------------
Date: Tue, 01 Aug 2000 19:56:01 GMT
From: gbacon@HiWAAY.net (Greg Bacon)
Subject: Re: References - I just don't get them!
Message-Id: <soeaqhpedbm73@corp.supernews.com>
In article <Ov4TjD$#$GA.328@cpmsnbbsa08>,
terri143 <terri143@email.msn.com> wrote:
: In a nut shell can some one point me to a good resource or examples of what
: references are used for? I know the docs and lots of other places explain
: this but I just don't get it. From what I understand references "point" to a
: variable but not "really"? I think that I may be using up memory needlessly
: because of my improper use of them.
Have you read the perlreftut manpage?
Greg
--
UNIX is running on at least five PDP-11, no two with the same complement
of hardware.
-- dmr (circa 1972)
------------------------------
Date: Tue, 1 Aug 2000 13:13:34 -0700
From: "Lauren Smith" <lauren_smith13@hotmail.com>
Subject: Re: References - I just don't get them!
Message-Id: <8m7b00$aos$1@brokaw.wa.com>
terri143 <terri143@email.msn.com> wrote in message
news:Ov4TjD$#$GA.328@cpmsnbbsa08...
> Hi,
>
> I have read docs, two perl books, many post on the subject and looked at a
> lot of other people's code trying to understand this. My programming
> experience is limited and that may be why I just don't get it.
>
> In a nut shell can some one point me to a good resource or examples of
what
> references are used for? I know the docs and lots of other places explain
> this but I just don't get it. From what I understand references "point" to
a
> variable but not "really"? I think that I may be using up memory
needlessly
> because of my improper use of them.
>
> Is there just like a real simple example that someone could give me? One
> that maybe I can see easy? I had a hard time understanding scopes and such
a
> while back. I am betting my money that these two are "close" together.
perlreftut purports to be a simple tutorial on references.
> Look, you can make fun of me or whatever you want to do if you will just
> help.
Haha, you have the same name as that 'Tickle' chick!
:-)
Happy reading!
Lauren
------------------------------
Date: Tue, 1 Aug 2000 22:57:27 +0100
From: "B Kemp" <hyagillot@tesco.net>
Subject: Re: References - I just don't get them!
Message-Id: <8m7hc2$16v$1@epos.tesco.net>
>In a nut shell can some one point me to a good resource or examples of what
>references are used for? I know the docs and lots of other places explain
>this but I just don't get it.
I think you get to see the need for pointers as you write more.
They might seem useless if you haven't written anything that needs them yet.
In some cases the first useful thing is to pass things into a subroutine.
check_color1($elephant);
check_color2(\$elephant);
If both give 'grey'. The first requires you to copy an elephant, the second
just passes a reference (<cage 57, the zoo>) telling the subroutine where
the 'elephant' is.
NOTE- most 'easy' questions get their replies passed by reference. You get:
perldoc somethingorother
Rather than 50 pages of stuff
------------------------------
Date: Tue, 01 Aug 2000 18:08:14 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: regular expression question....
Message-Id: <soe4ge2vdbm72@corp.supernews.com>
arun_rajappa@my-deja.com wrote:
: i have a program that generates file names of the format
:
: 20000801122801.deo
:
: where the first 6 chars signify the date.
:
: i would like to have a regular expression to verify that the input file
: is of this format - however, i am new to perl and dont know how i can
: do this.
:
: i tried the following, but it has limitations (allows names like
: 20001939******.deo)
:
: /2000[01][0-9][0123][0-9]\d\.deo/
:
: can anyone help me by telling me a more accurate way of doing this ?
: can it be done in a single regular expression ??
Well, you have to decide how tight a test you need. Simply doing
/^\d{14}\.deo/ will exclude your asterisks case, but doesn't validate the
date-time format at all.
For more rigorous testing, you probably want to bite the bullet and split
the string into its fields, validating each using simple comparisons or
(better) a trip through Time::Local and back. A regex-only approach would
get all bogged down dealing with month lengths and leap years and the
like.
--
| Craig Berry - http://www.cinenet.net/users/cberry/home.html
--*-- "Turning and turning in the widening gyre
| The falcon cannot hear the falconer." - Yeats, "The Second Coming"
------------------------------
Date: Tue, 1 Aug 2000 11:58:30 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Regular expression
Message-Id: <MPG.13f0bdb3242f5e2f98ac17@nntp.hpl.hp.com>
In article <3986EE9E.48AF8E9E@arnis-bsl.com> on Tue, 01 Aug 2000
10:37:02 -0500, Ilja Tabachnik <billy@arnis-bsl.com> says...
> Chrys wrote:
> >
> > Hello,
> > I need help for extracting a regex from a line .
> >
> > how to extract for instance:
> > the # 61242194 from the line:
> > /usr/data/testing/sid61242194/dt.out
> >
> > the pattern of the line is always the same.so i've tried to
> > use boundary word but it doesnt work.
> > I'm new to Perl and I need some guidance.
>
> If you want to match only the patterns *exactly* as above
> (and do not match anything else):
>
> $s = q(/usr/data/testing/sid61242194/dt.out);
>
> print "match: $1\n" if $s =~ m#^/usr/data/testing/sid(\d+)/dt.out$#;
Bzzt! Close, but... '.' is a regex metacharacter that must be escaped.
And there is ambiguity whether to match a string that ends in a newline
or not, because of the nature of the '$' regex metacharacter.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Tue, 01 Aug 2000 14:18:11 -0500
From: Ilja Tabachnik <billy@arnis-bsl.com>
Subject: Re: Regular expression
Message-Id: <39872273.69C5A90@arnis-bsl.com>
Larry Rosler wrote:
>
> In article <3986EE9E.48AF8E9E@arnis-bsl.com> on Tue, 01 Aug 2000
> 10:37:02 -0500, Ilja Tabachnik <billy@arnis-bsl.com> says...
> > Chrys wrote:
> > >
> > > Hello,
> > > I need help for extracting a regex from a line .
> > >
> > > how to extract for instance:
> > > the # 61242194 from the line:
> > > /usr/data/testing/sid61242194/dt.out
> > >
> > > the pattern of the line is always the same.so i've tried to
> > > use boundary word but it doesnt work.
> > > I'm new to Perl and I need some guidance.
> >
> > If you want to match only the patterns *exactly* as above
> > (and do not match anything else):
> >
> > $s = q(/usr/data/testing/sid61242194/dt.out);
> >
> > print "match: $1\n" if $s =~ m#^/usr/data/testing/sid(\d+)/dt.out$#;
>
> Bzzt! Close, but... '.' is a regex metacharacter that must be escaped.
You're right, as (almost) usually ;-)
> And there is ambiguity whether to match a string that ends in a newline
> or not, because of the nature of the '$' regex metacharacter.
>
Sure, but who knows what behavior exactly OP wants ?
Ilja.
------------------------------
Date: Tue, 01 Aug 2000 12:36:49 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Removing newline chars
Message-Id: <398726D1.CC4D32CB@stomp.stomp.tokyo>
Logan Shaw wrote:
> Godzilla! wrote:
> >> >Logan Shaw wrote:
> >> >> A textarea doesn't return \r\n if the user is using lynx.
> >> >> I just wrote a test script and found this out.
> >Fascinating. To which internet server did you upload
> >this script and what operating system is in use? Mind
> >posting a link to this script?
> Well, at first I just tested it on my machine at home, which is a
> Solaris 8 (Intel) system that uses Apache 1.3.12, perl 5.6.0, and
> CGI.pm 2.68.
> Just now, I've uploaded it to my school account, which runs on Solaris
> 7 (SPARC) and also also uses Apache 1.3.12, perl 5.005_02, and CGI.pm
> version 2.46.
> It does the same thing on both servers and with both lynx 2.7.1 and
> 2.8.1rel.2.
> Anyway, the URL is http://www.cs.utexas.edu/users/logan/linebreaks.cgi .
I am unable to replicate your results with my own tests.
Perhaps this is specific to certain lynx browser versions
or specific to a home system using a lynx operating system.
My system is DOS/Win 98 which returns specific characters,
seemingly despite an older lynx style browser.
*shrugs*
Interesting nonetheless.
Godzilla!
--
At one-hundred-fifty-five, I will rock you.
http://la.znet.com/~callgirl5/55.mid
------------------------------
Date: 1 Aug 2000 14:42:06 -0500
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: Removing newline chars
Message-Id: <8m796e$bev$1@provolone.cs.utexas.edu>
In article <398726D1.CC4D32CB@stomp.stomp.tokyo>,
Godzilla! <godzilla@stomp.stomp.tokyo> wrote:
>I am unable to replicate your results with my own tests.
>Perhaps this is specific to certain lynx browser versions
>or specific to a home system using a lynx operating system.
>My system is DOS/Win 98 which returns specific characters,
>seemingly despite an older lynx style browser.
It happens with lynx 2.7.1 on Solaris 7 (SPARC) and lynx-2.8.1rel.2 on
Solaris 8 (Intel). It does not happen with lynx 2.8.3dev.6 on Redhat
Linux 6.0.
So, it's clearly browser-specific. In fact, that fact that it doesn't
happen on a newer version of lynx may indicate that they decided it was
a bug and decided to fix it.
- Logan
------------------------------
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 3874
**************************************