[16518] in Perl-Users-Digest
Perl-Users Digest, Issue: 3930 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Aug 6 18:05:28 2000
Date: Sun, 6 Aug 2000 15:05:09 -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: <965599508-v9-i3930@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Sun, 6 Aug 2000 Volume: 9 Number: 3930
Today's topics:
Re: "Location:" How to? (Colin Keith)
Re: "Location:" How to? <john@torontonian.com>
Re: A program running every 24 hours (Colin Keith)
Re: a simple question (Colin Keith)
Re: bug in localtime()??? (J. B. Moreno)
Re: Destination Frame from PERL <senoc@hotmail.com>
mod_perl weirdness. noodle42@my-deja.com
Re: Problem w/anchored match <adamsone@voyager.net>
Re: reading and writing to dmb file ( .db) <flavell@mail.cern.ch>
Re: reading and writing to dmb file ( .db) (Colin Keith)
Re: reading and writing to dmb file ( .db) (Keith Calvert Ivey)
Re: semijoin() - a better way? <bart.lateur@skynet.be>
Re: split strings by number <jpl@research.att.com>
Re: split strings by number <jpl@research.att.com>
Subroutine References <grichards@flashcom.net>
Re: Tk module for Windows NT (Colin Keith)
Re: very cool routine <jb@yperite.demon.co.uk>
Re: very cool routine <jb@yperite.demon.co.uk>
Re: WWWBoard.PL (Colin Keith)
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sun, 06 Aug 2000 18:47:32 GMT
From: newsgroups@ckeith.clara.net (Colin Keith)
Subject: Re: "Location:" How to?
Message-Id: <8pij5.82$DT4.2759154@nnrp2.clara.net>
In article <398DA4B8.B2050326@torontonian.com>, Oktay <john@torontonian.com> wrote:
>If I remember correctly there was a concept like
>Location:http://domain.com
>in perl.
No, in the HTTP protocol, bother version 1.0 and 1.1. It is a header
returned by a server to indicate the new location of a resource for an
agent.
>My code is like this
>$url="http://foo.com";
>....
>print "<NOFRAMES>\n";
>print "Location:$url\n\n";
>print "</NOFRAMES>\n";
*waggles finger teacherly-like* Nope, that's not how you do it. Location is
a header. Basically you can't automatically redirect the person because you
can use META tags either because they come in the header of the document
serving the frameset/noframes tags. The easiest way is a link and an
explaination of why they can't see what they're expecting and that you've
nicely accommodated them and made them feel welcome.
Scoot yerself over to the people who know the truth - W3C - and look at
their example for HTML4.01:
<http://www.w3.org/TR/REC-html40/present/frames.html#h-16.4.1>
>That means it just prints above line(no redirection).
>Do I have to use something else (i.e. USE LWP etc) to make it work?
I would also suggest since you're playing with perl modules that you don't
try to use CGI.pm to play 'the browser guessing game' by looking at the
user agent name and trying to decide if it can/can't support frames. A
spider for instance won't match whatever you give, but will happily follow
an anchor you provide.
But since most of this isn't related to perl, further questions regarding
HTML/frames should go to the knowledgable members of
comp.infosystems.www.authoring.*
---
Colin Keith
Systems Administrator
Network Operations Team
ClaraNET (UK) Ltd. NOC
------------------------------
Date: Sun, 06 Aug 2000 19:31:13 GMT
From: Oktay <john@torontonian.com>
Subject: Re: "Location:" How to?
Message-Id: <398DBC1B.D4492DD1@torontonian.com>
Thank you for your response.
I will keep your suggestions in mind.
Best Regards
Colin Keith wrote:
>
> In article <398DA4B8.B2050326@torontonian.com>, Oktay <john@torontonian.com> wrote:
> >If I remember correctly there was a concept like
> >Location:http://domain.com
> >in perl.
>
> No, in the HTTP protocol, bother version 1.0 and 1.1. It is a header
> returned by a server to indicate the new location of a resource for an
> agent.
>
> >My code is like this
> >$url="http://foo.com";
> >....
> >print "<NOFRAMES>\n";
> >print "Location:$url\n\n";
> >print "</NOFRAMES>\n";
>
> *waggles finger teacherly-like* Nope, that's not how you do it. Location is
> a header. Basically you can't automatically redirect the person because you
> can use META tags either because they come in the header of the document
> serving the frameset/noframes tags. The easiest way is a link and an
> explaination of why they can't see what they're expecting and that you've
> nicely accommodated them and made them feel welcome.
>
> Scoot yerself over to the people who know the truth - W3C - and look at
> their example for HTML4.01:
>
> <http://www.w3.org/TR/REC-html40/present/frames.html#h-16.4.1>
>
> >That means it just prints above line(no redirection).
> >Do I have to use something else (i.e. USE LWP etc) to make it work?
>
> I would also suggest since you're playing with perl modules that you don't
> try to use CGI.pm to play 'the browser guessing game' by looking at the
> user agent name and trying to decide if it can/can't support frames. A
> spider for instance won't match whatever you give, but will happily follow
> an anchor you provide.
>
> But since most of this isn't related to perl, further questions regarding
> HTML/frames should go to the knowledgable members of
> comp.infosystems.www.authoring.*
>
> ---
> Colin Keith
> Systems Administrator
> Network Operations Team
> ClaraNET (UK) Ltd. NOC
------------------------------
Date: Sun, 06 Aug 2000 18:50:35 GMT
From: newsgroups@ckeith.clara.net (Colin Keith)
Subject: Re: A program running every 24 hours
Message-Id: <%rij5.83$DT4.2759502@nnrp2.clara.net>
In article <02e34e67.a8a91690@usw-ex0103-023.remarq.com>, Diablito <diab.litoNOdiSPAM@usa.net.invalid> wrote:
>Can anyone give me some lines of code to have a perl program
>running every 24 hours.I know it was posted at least 100
>times,my apologies.The problem is that I currently know just the
>very basic of Perl and the previous posts about this topic
>sounds like Chinese to me.Thanks anyone.
You'd be better off scheduling it to run with a program like Cron. (you can
get it for DOS as well as on UNIX) or if you're on win32 scheduler (or
similar) Yes, you can put a big sleep() in there, but what if someone
reboots the computer, it crashes, it leaks memory and slowly sucks away your
resources ... far better to have something start it and let it run, catch
errors and deliver them to you.
---
Colin Keith
Systems Administrator
Network Operations Team
ClaraNET (UK) Ltd. NOC
------------------------------
Date: Sun, 06 Aug 2000 19:10:36 GMT
From: newsgroups@ckeith.clara.net (Colin Keith)
Subject: Re: a simple question
Message-Id: <MKij5.84$DT4.2761909@nnrp2.clara.net>
In article <uZ#TcM8$$GA.192@cpmsnbbsa09>, "VTAM_203" <VTAM_203@email.msn.com> wrote:
>I have a script for a class from one of my perl books. There's one line in
>it I don't understand.
>
>Here's the script for the constructor of this class:
>
>sub new {
> my $proto = shift; # allow use as a class or object method
> my $class = ref($proto) || $proto;
> return bless({}, $class);
>}
>
>Can anybody explain to me what the "my $class = ref($proto) || $proto
>statement does"?
Uh huh. It is checking to see if $proto is a reference to a variable. If it
is, it assigns the reference ('effectively' the pointer to) to the variable
to $class. If it isn't a reference to a variable, then it assigns the value
of $proto. Long hand:
my($class);
if(ref($proto)){
$class = ref($proto);
} else {
$class = $proto;
}
And to prempt your next question, *why*: This is an object's 'constructor',
and bless() turns the variable that is its first parameter (here an
anonymous hash - { } ) into an object of the class given in its second
parameter. So as perlobj says:
Or if you expect people to call not just CLASS->new() but
also $obj->new(), then use something like this.
It then allows people to do:
maia% perl -w -Mstrict -MFileHandle
my($fh) = FileHandle->new();
my($fh2) = $fh->new();
print "fh ref = ", ref($fh), "\nfh2 ref = ", ref($fh2), "\n";
fh ref = FileHandle
fh2 ref = FileHandle
Btw, "Object Oriented Perl - Damian Conway" is an excellent book. (Good
enough to read on the underground for the few stations it takes me to fall
asleep:)
---
Colin Keith
Systems Administrator
Network Operations Team
ClaraNET (UK) Ltd. NOC
------------------------------
Date: Sun, 6 Aug 2000 14:32:09 -0400
From: planb@newsreaders.com (J. B. Moreno)
Subject: Re: bug in localtime()???
Message-Id: <1eey4s4.1djqrq71ftki8dN%planb@newsreaders.com>
Bart Lateur <bart.lateur@skynet.be> wrote:
> J. B. Moreno wrote:
>
> >And why were you so convinced that it was a bug even after being told
> >there was no bug?
>
> Because it sounds like a design error?
I think a design error has to be a bit more of a problem than this
before calling it a bug.
And that's not what he was talking about anyway -- or at least it didn't
seem that way to me. It looked to me like he was denying that the
documentation said that would be the result under those circumstances.
--
JBM (that's me) thinks that Mark Twain said "The difference between the
right word and the almost right word is like the difference between
lightning and a lightning bug."?
------------------------------
Date: Mon, 7 Aug 2000 04:35:47 +0800
From: "curious" <senoc@hotmail.com>
Subject: Re: Destination Frame from PERL
Message-Id: <398dd369$0$14918@echo-01.iinet.net.au>
Would a cgi script for each frame do the trick ?
http://www.myserver.com/cgi-bin/sqloutput.cgi?frame=top
http://www.myserver.com/cgi-bin/sqloutput.cgi?frame=left
etc...
------------------------------
Date: Sun, 06 Aug 2000 21:45:45 GMT
From: noodle42@my-deja.com
Subject: mod_perl weirdness.
Message-Id: <8mkma9$qjk$1@nnrp1.deja.com>
Hello,
I'm toying around with mod_perl. I've tested that my installation works
with some simple scripts from the eg/ directory - everything a-okay
(Apache 1.3.12 - modperl 1.24).
Taking it a bit further I read Randal Schwartz's Web Technique column 41
(http://www.stonehenge.com/merlyn/WebTechniques/col41.html) and decided
to try that.
SO : I have a .htaccess file with :
---
SetHandler perl-script
PerlHandler noodle::Pictures
PerlSendHeader On
---
and in /usr/local/apache/lib/perl/noodle/Pictures.pm (file) is the
script itself.
The script is totally stripped down to :
---
package noodle::Pictures;
use strict;
sub handler
{
print "Content-type: text/html\n\n";
print "<b>Date: ", scalar localtime, "</b><br>\n";
return 0;
}
---
The problem : It works every 4th or 5th time (displaying the time) - the
remaining times I get an "internal server error"[1] or a "Document
contained no data" .
[1] when this is the case the error_log says :
Undefined subroutine &noodle::Pictures::handler
called.
Please help..
Thanks..
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Sun, 6 Aug 2000 14:54:20 -0400
From: "Eric Adamson" <adamsone@voyager.net>
Subject: Re: Problem w/anchored match
Message-Id: <398db49e$0$60937$2dcedb17@news.voyager.net>
Thanks for taking a look at this, everyone. The problem with using
/^\d\d\d-\d\d\d\d.*$/ is that I am developing state logic for reading in a
file which, from a database perspective, is not normalized. I must be able
to distinguish lines of the form /^\d\d\d-\d\d\d\d$/ and
/^\d\d\d-\d\d\d\d.*$/, and handle them differently. Phone numbers taken
from lines of the latter format will have already been encountered in lines
of the former format. I realize I can use complex data structures to elim-
inate duplicates, but for now, as an educational exercise, I wish merely to
identify each type of line that is encountered in the file, so that I can
develop my state logic.
After closer inspection, I found that "elvis" -- the version of vi that
I use -- is the culprit. Newer versions of elvis check the file to deter-
mine the end-of-line character, and compensate accordingly when reading
into their buffer. This feature prevents the user from seeing the telltale
^M character when viewing DOS text files. It apparently is not concealing
them -- it actually does not read them into the buffer, hence attempts to
replace ^M (a la %s/^M//g) fail.
This behavior is configured in the file elvis.brf (before reading file):
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" TAKE A GUESS AT THE BUFFER'S TYPE
let! readeol=fileeol(filename)
To get the more honest behavior, where "what you see is what you got",
comment out the third line above by inserting a double-quote symbol at
the line's beginning.
(For those having trouble finding elvis.brf: On my system, the full
pathname is /usr/share/elvis-2.1_4/elvis.brf)
Thanks all, for your assistance.
Regards,
----------------------------------------------------------------------------
Eric Adamson
BS - Computer Engineering UNIX -- It's even easier WITHOUT
Michigan State University the monkey glove!
----------------------------------------------------------------------------
Prasanth A. Kumar <kumar1@home.com> wrote in message
news:m3ya2b3ydw.fsf@C654771-a.frmt1.sfba.home.com...
>
> What about /^\d\d\d-\d\d\d\d.*$/ which will match anything starting
> with a phone number followed by optional name or other stuff. You can
> also shorten that down to /^\d{3}-\d{4}.*$/ if you like. BTW, the way
> I tested this is using perl in interactive mode as 'perl -de 0' and
> then you can try most any perl commands out interactively.
>
> --
> Prasanth Kumar
> kumar1@home.com
> "Eric Adamson" <adamsone@voyager.net> writes:
>
> > I'm processing a text file, and wish to identify lines that contain
phone
> > numbers. For the moment, I'm testing my routine by just printing them
out.
> > I wish to find lines matching ###-####, with no other text appearing on
the
> > line. Why doesn't the following work?
> >
> > SAMPLE INPUT DATA:
> >
> > 555-3494
> > 555-3949
> > 448-3944 Bob Smith
> >
> > MY SCRIPT:
> >
> > #!/usr/bin/perl
> >
> > open(IN, "<testfile.txt");
> >
> > while (<IN>) {
> > if (/^\d\d\d-\d\d\d\d$/) {
> > print $_;
> > }
> > }
> >
> > close IN;
> >
> > I tried removing the anchors, and testing for a second condition -- that
the
> > line have length=8 -- and *still* get no matches! Perl returns a length
of
> > 10 for the lines that I'm interested in -- chomping only takes it down
to 9.
> > Lines are broken with linefeeds, there are no carriage returns. A hex
> > editor shows each line to be 9 characters long (including 0x0A, the
> > linefeed).
> <snip>
------------------------------
Date: Sun, 6 Aug 2000 19:42:42 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: reading and writing to dmb file ( .db)
Message-Id: <Pine.GHP.4.21.0008061941550.25484-100000@hpplus03.cern.ch>
On Sun, 6 Aug 2000 drdementor@my-deja.com wrote:
> > You've now wasted another pointless round of discussion, and decreased
> > the chance of getting helped. I really don't know why so many newbies
> > approach usenet in this self-destructive way.
> btw if im wasting yoru time dont respond to me with your arrogent
> talk...
Only too glad to comply.
bye.
------------------------------
Date: Sun, 06 Aug 2000 19:41:55 GMT
From: newsgroups@ckeith.clara.net (Colin Keith)
Subject: Re: reading and writing to dmb file ( .db)
Message-Id: <7cjj5.85$DT4.2765278@nnrp2.clara.net>
In article <8mk2bs$d5s$1@nnrp1.deja.com>, drdementor@my-deja.com wrote:
>use Fctl;
>use NDBM_File;
>tie %hash, "NDBM_File" , 'data' . O_RDWR|O_CREAT|O_EXCL , 0644; $hash
>{drink} = 'root beer';(57)
>untie $hash;(61)
>
>im not going to include the entire program its jsut a bunch of pascing
>and print statements that i already teasted and that part is bullet
>proof. the code i posted here, i inserted into my program, from a book
>published in late 99, copied verbatum...
Maybe from the book, but you *have* to copy and paste. There are (still) two
errors in there which I can only assume are typographical errors when you've
retyped it. If it is pasted then that's (part) of your problem. If it
isn't... then please take this as a hint to let the computer do the work
because its quicker and (virtually) impossible for it to make errors.
use Fctl; => use Fcntl;
'data'.O_RDWR|O_CREAT|O_EXCL => that should be a , not a .
untie $hash; => pointless you're dealing with %hash
>sorry for the confusion.. oh the hash was not declaired anywhere sle in
>the program, files not worked with any other place than here, its all
>independent code, i just figured someone would see something obviously
>wring with it possibly.
If (as other posts in this thread imply) the system you're on is using
perl4, and you just enter #!/usr/bin/perl, try #!/usr/bin/perl5 so (older)
installations don't symlink the two in case anyone needed the older version
still. You should also use the switch -w and ideally also use the 'strict'
directive. I.e.
#!/usr/bin/perl -w
use strict;
This will generate warning messages for things that go wrong and stop some
of the things that can go wrong. For example the untie $hash.
If you want more verbose warning messages
#!/usr/bin/perl -wF
>error....################################## start #############Illegal
>modulus of constant zero in file write_to_database.cgi at line 61, next
>2 tokens "file_hash;"
>Execution of write_to_database.cgi aborted due to compilation errors.
>error....#################################end #######################
To add evidence to the problem being with the version of perl your
system doesn't seem to recognise tie(). Since you've used it in the keyword
format, it would not be interpretted as tie(%hash ... ); but as a bareword,
it generates that message:
maia% perl
print 'xxx'%hash;
Operator or semicolon missing before %hash at - line 1.
Ambiguous use of % resolved as operator % at - line 1.
Illegal modulus zero at - line 1.
Col.
---
Colin Keith
Systems Administrator
Network Operations Team
ClaraNET (UK) Ltd. NOC
------------------------------
Date: Sun, 06 Aug 2000 20:54:50 GMT
From: kcivey@cpcug.org (Keith Calvert Ivey)
Subject: Re: reading and writing to dmb file ( .db)
Message-Id: <398ece49.5695352@news.newsguy.com>
drdementor@my-deja.com wrote:
> kcivey@cpcug.org (Keith Calvert Ivey) wrote:
>> drdementor@my-deja.com wrote:
>>
>> >modulus of constant zero in file write_to_database.cgi at line 61,
>next
>> >2 tokens "file_hash;"
>> >Execution of write_to_database.cgi aborted due to compilation errors.
>>
>use Fctl;
>use NDBM_File;
>tie %hash, "NDBM_File" , 'data' . O_RDWR|O_CREAT|O_EXCL , 0644; $hash
>{drink} = 'root beer';(57)
>untie $hash;(61)
>
>im not going to include the entire program its jsut a bunch of pascing
>and print statements that i already teasted and that part is bullet
>proof. the code i posted here, i inserted into my program, from a book
>published in late 99, copied verbatum...
I didn't ask you to include the entire program. I said the
*relevant* part around line 61. If 57 and 61 are supposed to be
line numbers above, then you must have omitted some lines. Note
that the error message refers to "file_hash", which does not
occur in the snippet you've shown us.
I suspect you've retyped the code, rather than copying and
pasting as I recommended, and have typed $hash where the real
code has %file_hash. Who knows what other differences there
might be between this code and your real code, so it's a waste
of time to examine it in detail. We'll focus on typos that
aren't in the real code, while missing the typos that are in the
real code, which we haven't seen.
In any case, it appears that the real problem is that you're
using Perl 4, which is ancient, has security weaknesses, and
won't let you do what you're trying to do. Upgrade.
--
Keith C. Ivey <kcivey@cpcug.org>
Washington, DC
------------------------------
Date: Sun, 06 Aug 2000 20:32:24 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: semijoin() - a better way?
Message-Id: <oqiros4gm0j0l91ma7ctepibgmd788qasn@4ax.com>
Tim wrote:
>Careful...both of those solutions eat the original list.
That's ok in a sub.
--
Bart.
------------------------------
Date: Sun, 6 Aug 2000 18:46:25 GMT
From: "John P. Linderman" <jpl@research.att.com>
Subject: Re: split strings by number
Message-Id: <398DB281.5FA6B9F0@research.att.com>
Larry Rosler wrote:
> In article <8mduuf$7k3$1@orpheus.gellyfish.com> on 4 Aug 2000 09:30:07
> +0100, Jonathan Stowe <gellyfish@gellyfish.com> says...
> > On Thu, 03 Aug 2000 15:59:04 GMT oderus54@my-deja.com wrote:
> > > How would i split strings by number, like for example;
> >
> > > $blah = "abcdefghijklmn";
> > > #now i want $string1 = "abc", $string2 = "defgh", $string3 = "ijk",
> > > $string4 = "lmn"
> >
> > TIMTOWTDI (though some ways are more sensible than others ):
>
> ...
>
> Indeed, but no way would I include the following in a serious benchmark.
>
> > {
> > my $i = 0;
> > my ( $string1,
> > $string2,
> > $string3,
> > $string4);
> >
> > foreach ( split //, $string )
> > {
> > ${
> > $i < 3 ? \$string1 :
> > $i < 8 ? \$string2 :
> > $i < 11 ? \$string3 :
> > \$string4
> > } .= $_;
> > $i++
> > }
> >
> > print "$string1,$string2,$string3,$string4\n";
> > }
>
> I replaced this with Anno Siegel's sensible attempt, which he guessed to
> be "Very probably slower too, though I didn't check. But not really
> messy, and easily maintained." I did check; he is right on all counts.
>
> #!/usr/local/bin/perl -w
> use strict;
> use Benchmark;
>
> use vars '$s';
> $s = 'abcdefghijklmn';
>
> timethese( 1 << (shift || 0), {
> A_Unpack => 'my @a = unpack "A3A5A3A3", $s',
> B_Regex => 'my @a = $s =~ /(.{3})(.{5})(.{3})(.{3})/s',
> C_Substr => 'my @a = (substr($s, 0, 3),
> substr($s, 3, 5),
> substr($s, 8, 3),
> substr($s, 11, 3))',
> D_Siegel => 'my $x = $s;
> my @a = map substr($x, 0, $_, ""), 3, 5, 3, 3',
> } );
> __END__
>
> Output:
>
> Benchmark: timing 262144 iterations of A_Unpack, B_Regex, C_Substr,
> D_Siegel...
> A_Unpack: 10 wallclock secs ( 8.39 usr + 0.00 sys = 8.39 CPU) @
> 31241.09/s (n=262144)
> B_Regex: 10 wallclock secs (10.48 usr + 0.00 sys = 10.48 CPU) @
> 25001.81/s (n=262144)
> C_Substr: 8 wallclock secs ( 7.23 usr + 0.00 sys = 7.23 CPU) @
> 36242.78/s (n=262144)
> D_Siegel: 16 wallclock secs (14.92 usr + 0.00 sys = 14.92 CPU) @
> 17567.62/s (n=262144)
>
> So substr(), the hardest to maintain, is also the fastest (as usual
> :-). But unpack() does quite well.
>
> --
> (Just Another Larry) Rosler
> Hewlett-Packard Laboratories
> http://www.hpl.hp.com/personal/Larry_Rosler/
> lr@hpl.hp.com
It is perhaps worth mentioning that the A_Unpack
code isn't quite the same as the others. The "A" format
item trims trailing blanks, which may or may not
be what we want, and may or may not explain
the performance ``hit''.
Perhaps Perl 6 will give us a format item that just
splits on bytes, blanks or nulls be damned (and
endian-sensitive quad int formats).
John P. Linderman
jpl@research.att.com
------------------------------
Date: Sun, 6 Aug 2000 19:47:01 GMT
From: "John P. Linderman" <jpl@research.att.com>
Subject: Re: split strings by number
Message-Id: <398DC0B5.AE3F60B3@research.att.com>
"John P. Linderman" wrote:
> Larry Rosler wrote:
>
> snip ....
> > #!/usr/local/bin/perl -w
> > use strict;
> > use Benchmark;
> >
> > use vars '$s';
> > $s = 'abcdefghijklmn';
> >
> > timethese( 1 << (shift || 0), {
> > A_Unpack => 'my @a = unpack "A3A5A3A3", $s',
> > B_Regex => 'my @a = $s =~ /(.{3})(.{5})(.{3})(.{3})/s',
> > C_Substr => 'my @a = (substr($s, 0, 3),
> > substr($s, 3, 5),
> > substr($s, 8, 3),
> > substr($s, 11, 3))',
> > D_Siegel => 'my $x = $s;
> > my @a = map substr($x, 0, $_, ""), 3, 5, 3, 3',
> > } );
> > __END__
> >
> > Output:
> >
> > Benchmark: timing 262144 iterations of A_Unpack, B_Regex, C_Substr,
> > D_Siegel...
> > A_Unpack: 10 wallclock secs ( 8.39 usr + 0.00 sys = 8.39 CPU) @
> > 31241.09/s (n=262144)
> > B_Regex: 10 wallclock secs (10.48 usr + 0.00 sys = 10.48 CPU) @
> > 25001.81/s (n=262144)
> > C_Substr: 8 wallclock secs ( 7.23 usr + 0.00 sys = 7.23 CPU) @
> > 36242.78/s (n=262144)
> > D_Siegel: 16 wallclock secs (14.92 usr + 0.00 sys = 14.92 CPU) @
> > 17567.62/s (n=262144)
> >
> > So substr(), the hardest to maintain, is also the fastest (as usual
> > :-). But unpack() does quite well.
> It is perhaps worth mentioning that the A_Unpack
> code isn't quite the same as the others. The "A" format
> item trims trailing blanks, which may or may not
> be what we want, and may or may not explain
> the performance ``hit''.
>
> Perhaps Perl 6 will give us a format item that just
> splits on bytes, blanks or nulls be damned (and
> endian-sensitive quad int formats).
And perhaps I should read the documentation more thoroughly
before spouting. Format item "a" unpacks data verbatim,
and slightly faster than "A" (on my PC), though not
as fast as substr:
a_Unpack => 'my @a = unpack "a3a5a3a3", $s',
Benchmark: timing 262144 iterations of
A_Unpack, B_Regex, C_Substr, D_Siegel, a_Unpack...
A_Unpack: 2 wallclock secs ( 2.50 usr + 0.02 sys = 2.52 CPU) @
104025.40/s (n=262144)
B_Regex: 3 wallclock secs ( 3.18 usr + 0.01 sys = 3.19 CPU) @
82176.80/s (n=262144)
C_Substr: 1 wallclock secs ( 2.22 usr + 0.02 sys = 2.24 CPU) @
117028.57/s (n=262144)
D_Siegel: 3 wallclock secs ( 4.32 usr + 0.02 sys = 4.34 CPU) @
60401.84/s (n=262144)
a_Unpack: 2 wallclock secs ( 2.37 usr + 0.00 sys = 2.37 CPU) @
110609.28/s (n=262144)
John P. Linderman
jpl@research.att.com
------------------------------
Date: Sun, 6 Aug 2000 15:00:09 -0700
From: "Gabe" <grichards@flashcom.net>
Subject: Subroutine References
Message-Id: <sornogj263a112@corp.supernews.com>
I have a vairable with the name of a subroutine in it. I want to execute
that subroutine but I keep getting an error. The camel book says it's
because only hard referneces are allowed by use strict and symbolic
references are disallowed. I've just begun using references so I don't
really understand the difference or the problem. Please help.
my $referer = $cgi->referer();
my $go = $1 if $referer =~ /go\=(.*)\&/;
&$go($sessionid, 'Record Added');
So $go contains something like GetEditEvent, and I suppose it's a symbolic
reference. Can I convert it to a hard reference?
Gabe
------------------------------
Date: Sun, 06 Aug 2000 18:18:22 GMT
From: newsgroups@ckeith.clara.net (Colin Keith)
Subject: Re: Tk module for Windows NT
Message-Id: <OZhj5.80$DT4.2755694@nnrp2.clara.net>
In article <8mg8hr$3or$0@216.39.131.175>, homer.simpson@springfield.nul (Homer Simpson) wrote:
>junk after document element at line 1, column 63, byte 63 at
>C:/Perl/site/lib/XML/Parser.pm line 168
>C:\>
Hmmm, looks like the XML page you're getting is broken.
Try getting it from a different site?
set repository NAME URL
Otherwise if PPM still doesn't work, the activestate docs say you can get it
from them in zip format:
http://www.activestate.com/packages/zips
hope it helps.
Col.
Damn, my bug's wandered off. I think its trying to steal my coke bottle :p
---
Colin Keith
Systems Administrator
Network Operations Team
ClaraNET (UK) Ltd. NOC
------------------------------
Date: Sun, 06 Aug 2000 22:14:52 +0100
From: jb <jb@yperite.demon.co.uk>
Subject: Re: very cool routine
Message-Id: <398DD54C.C04E101A@yperite.demon.co.uk>
Robin Bank wrote:
>
> splice ?
[...]
> less big and bulky than mine... In fact, probably more so, because mine is
> the bear minimum ammount of code needed. (pretty much)
This would have to be proven before it is believed.
------------------------------
Date: Sun, 06 Aug 2000 22:23:58 +0100
From: jb <jb@yperite.demon.co.uk>
Subject: Re: very cool routine
Message-Id: <398DD76E.6C8CE370@yperite.demon.co.uk>
> > >Next time I won't. Can't you read the previous posts?? It was a
> > >misunderstanding. I was un-aware that the builtin functions were written
> in
> > >C rather than PERL...
Robin Bank wrote:
>
> OK.. Good answer.
>
A bit of friendly advice. If you're going to post to usenet please learn
how.
This page explains a few things and though it refers to the UK it is
applicable for usenet as a whole:
http://www.usenet.org.uk/ukpost.html
------------------------------
Date: Sun, 06 Aug 2000 18:36:30 GMT
From: newsgroups@ckeith.clara.net (Colin Keith)
Subject: Re: WWWBoard.PL
Message-Id: <Oeij5.81$DT4.2757702@nnrp2.clara.net>
In article <0naooss48hjlajsthd8510dcc5v7rb1dni@4ax.com>, Bart Lateur <bart.lateur@skynet.be> wrote:
>So: what's the quickest way to copy the old file permissions and
>preferably file ownership from the old file to the new?
My choice would be man perlfunc /stat
maia% ls -l x x2
-rw------- 1 colin staff 27 Aug 6 17:28 x
-rwxrwxrwx 1 colin staff 0 Aug 6 19:33 x2
maia% perl -w -Mstrict;
my($mode, $uid, $gid) = (stat('x'))[2,4,5];
chmod($mode&07777, 'x2');
chown($uid, $gid, 'x2');
maia% ls -l x x2
-rw------- 1 colin staff 27 Aug 6 17:28 x
-rw------- 1 colin staff 0 Aug 6 19:33 x2
---
Colin Keith
Systems Administrator
Network Operations Team
ClaraNET (UK) Ltd. NOC
------------------------------
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 3930
**************************************