[8288] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 1905 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Feb 16 16:27:18 1998

Date: Mon, 16 Feb 98 13:01:53 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Mon, 16 Feb 1998     Volume: 8 Number: 1905

Today's topics:
    Re: Location: returns empty document? <chris@ixlabs.com>
        Modules for axcessing the Phone Book Data file from Out <wizard@eznet.net>
        my $scalar vs. my($scalar) (was Re: FAQless Forays (was (Jonathan Feinberg)
    Re: Passing values into a subroutine from an array... <tchrist@mox.perl.com>
    Re: Perl Compilers (Martien Verbruggen)
    Re: perl NT : how get %env of a remote host ? (Martien Verbruggen)
        perldoc for Win32 (was Re: Why is Tom Christiansen so r (Jonathan Feinberg)
    Re: Printing $query->param in a here-doc? <tchrist@mox.perl.com>
        Q: XSUB/Perl Performance (long) <eriko@austin.ibm.com>
    Re: regexp: /^[800|888]/ vs. /^8[0{2}|8{2}]/ <*@qz.to>
    Re: regexp: /^[800|888]/ vs. /^8[0{2}|8{2}]/ (Jack Applin)
    Re: regexp: /^[800|888]/ vs. /^8[0{2}|8{2}]/ (Abigail)
    Re: regexp: /^[800|888]/ vs. /^8[0{2}|8{2}]/ <*@qz.to>
    Re: RFC about "Matt's Script Archive" <dannyman@arh0300.urh.uiuc.edu>
    Re: RFC about "Matt's Script Archive" (Bart Lateur)
    Re: RFC about "Matt's Script Archive" (Nathan V. Patwardhan)
    Re: RFC about "Matt's Script Archive" (Bart Lateur)
        Running Perl <momiji@slip.net>
    Re: Searching a file for a word. <tchrist@mox.perl.com>
    Re: Sort help please! (Craig Berry)
    Re: Testing integer (Craig Berry)
    Re: Testing integer (Craig Berry)
        Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Sun, 15 Feb 1998 15:42:47 -0800
From: Chris Schoenfeld <chris@ixlabs.com>
To: Chad Casselman <c2@3-g.com>
Subject: Re: Location: returns empty document?
Message-Id: <34E77D77.E5BCC886@ixlabs.com>

I beleive location redirects require a fully qualified URL:
"Location: http://www.yahoo.com\n\n";

-Chris

Chad Casselman wrote:
> 
> P. Schmitz wrote:
> >
> > Hi everyone,
> >
> > Does anyone have any idea why the following perl script:
> >
> > print "Location: www.yahoo.com\n\n";
> >
> > doesn't redirect my browser to Yahoo!, but instead gives a 'Document
> > contains no data' message? The same thing in a C++ CGI-bin works
> > perfectly. Returning HTML works perfectly. But for some reason,
> > redirects like the above don't work from perl scripts...
> >
> > I'm running perl 5 on Windows NT Server 4.0 with MS IIS. I sure hope you
> > know what's going on, because this has me baffled...
> >
> > Pepijn.
> >
> 
> I am having the same trouble!  What is up with NT!  I am unix programmer
> but this crap don't work on NT!  Please reply!
> 
> Thanks,
> c2

-- 
---
Chris Schoenfeld
IX Development Laboratories
Santa Rosa, California


------------------------------

Date: Sat, 14 Feb 1998 21:38:11 -0500
From: "David A. Frantz" <wizard@eznet.net>
Subject: Modules for axcessing the Phone Book Data file from Outlook Express
Message-Id: <34e65406.0@news.eznet.net>

What I'am looking for is a perl module that will allow me to access the
Outlook Express Phnoebook File.

The intent is to custom print the data file with the records sorted by the
Company Field.    If anybody has an idea or has done this pointers would be
nice.


Thanks

Dave





------------------------------

Date: Sun, 15 Feb 1998 09:58:30 -0500
From: jdf@pobox.com (Jonathan Feinberg)
Subject: my $scalar vs. my($scalar) (was Re: FAQless Forays (was: Code Example Needed))
Message-Id: <MPG.f50cc72430591a99896d3@news.concentric.net>

chip@mail.atlantic.net said...
> According to gabor@vmunix.com (Gabor):
> >I always put my variables declared with 'my' or 'local'
> >into parens, well most of the time.
> 
> Consider that:
> 
>     if (my($x) = undef) { print "oops\n" }
> 
> prints, while
> 
>     if (my $x = undef) { print "oops\n" }
> 
> does not.
> 
> Sometimes the difference is more than cosmetic.

This post sent me to perl -d, perldoc, and the Camel for a few minutes.  I 
hadn't deduced this behavior from the docs.  However, there's no arguing with:

  DB<9> print scalar(my $robot = undef);

  DB<10> print scalar(my($robot)  = undef);
1

The camel does indeed distinguish between the scalar assignment and list 
assignment forms of my() (Camel 2, p189, bottom of page).  It is up to the 
reader, though, to understand the implication that the value of my() is 
therefore a list.  I'm not ashamed to say that I find this implication subtle!  
Thanks, Chip.

-- 
Jonathan Feinberg    jdf@pobox.com    Sunny Brooklyn, NY


------------------------------

Date: 15 Feb 1998 23:56:26 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Passing values into a subroutine from an array...
Message-Id: <6c7vba$qhc$3@csnews.cs.colorado.edu>

 [courtesy cc of this posting sent to cited author via email]

In comp.lang.perl.misc, 
    Premgith  Vidyanandan <vidyanan@pilot.msu.edu> writes:
:The question I have is how can I pass the values from the call to the
:subroutine for different values of the array, 

I think you need to read the perlsub manpage, include with 
your perl distribution.  While you're at it, you should read 
the FAQs, too.  And the rest of the manpages.  

:the same subroutine with @array[1];@array[2] .... 

And you better turn on -w, since you're accessing the array 
incorrectly.  What do I mean `incorrectly'?  That, too, can
be found in the FAQ.

I can't believe people try to use Perl without ever having
read the manpages.  I can't.

--tom
-- 
	Tom Christiansen	tchrist@jhereg.perl.com

    "If ease of use is the highest goal, we should all be driving golf carts."
    	--Larry Wall


------------------------------

Date: 15 Feb 1998 23:09:57 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Perl Compilers
Message-Id: <6c7sk5$r8n$5@comdyn.comdyn.com.au>

In article <6c1l7i$c8f$1@usenet.logical.net>,
	"Vince M." <vince@oxxfordinfo.com> writes:
> This may be a naive question -- does anyone know if a true compiled version
> of Perl exists? I have a need for speed...

1) All versions of perl are compiled. Otherwise they wouldn't work.
2) perl compiles all the scripts you feed it, before executing them.
3) If you are looking for something to compile Perl code into
   bytecode, please do a search on dejanews. That question has been asked
   at least 10 times the last month. Also check the perl faq.

perldoc perlfaq

Martien
-- 
Martien Verbruggen                  | 
Webmaster www.tradingpost.com.au    | 
Commercial Dynamics Pty. Ltd.       | Curiouser and curiouser, said Alice.
NSW, Australia                      | 


------------------------------

Date: 15 Feb 1998 23:06:10 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: perl NT : how get %env of a remote host ?
Message-Id: <6c7sd2$r8n$4@comdyn.comdyn.com.au>

In article <34E42861.76540526@swisslife.be>,
	denis <denis@swisslife.be> writes:
> With perl under NT, we try to get the %env of a remote host.
> Does anybody know how to proceed ?

I don't think you really understand what is stored in %ENV (capitals).
It contains the environment variables for the running program. There
is no such thing as a %ENV of a remote host. I am not even in the
clear about what you want to do... Do you want to connect to a remote
machine, and get some information from it? And if so, what information
would you want to get? 

OR, which I think is probably the case, are you writing some CGI
application, and are you interested in what is stored in the CGI's
environment when it executes?

foreach (keys %ENV)
{
	print "$_ : $ENV{$_}\n";
}

Please bear in mind: The environment has nothing to do with the remote
host. Your web server sets it, according to the CGI specification,
after which you can access those environment variables in your CGI
program. Please read some documentation on CGI programming.

Martien
-- 
Martien Verbruggen                  | 
Webmaster www.tradingpost.com.au    | The gene pool could use a little
Commercial Dynamics Pty. Ltd.       | chlorine.
NSW, Australia                      | 


------------------------------

Date: Sun, 15 Feb 1998 03:01:41 -0500
From: jdf@pobox.com (Jonathan Feinberg)
Subject: perldoc for Win32 (was Re: Why is Tom Christiansen so rude?)
Message-Id: <MPG.f506aedd3953a679896d2@news.concentric.net>

zenin@best.com said...
> Steffen Beyer <sb@en.muc.de> wrote:
> : Kent Perrier <kperrier@Starbase.NeoSoft.COM> wrote:
> : > But the FSF has provided a functional equivalent of the unix grep for
> : > Bill'$ broken OS.
> : Unfortunately, beginners and poor PC owners might not be aware of that... :-)
> 	>snip<
> 
> 	C:\> wordpad perlfaq
> 	^F
> 
> 	It really can't be *that* hard... :^)

I use the Adobe pdf version of perldoc.  It contains the entire perldoc in a 
single document, is easily searchable, has a good TOC, and is very easy on the 
eyes.  I highly recommend it to all fellow POBs.

  http://language.perl.com/CPAN/authors/id/BMIDD/perlbook-5.004_01.tar.gz

-- 
Jonathan Feinberg    jdf@pobox.com    Sunny Brooklyn, NY


------------------------------

Date: 15 Feb 1998 23:53:39 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Printing $query->param in a here-doc?
Message-Id: <6c7v63$qhc$2@csnews.cs.colorado.edu>

 [courtesy cc of this posting sent to cited author via email]

In comp.lang.perl.misc, mark666769@aol.com (Mark666769) writes:
:Is it possible to print the results of a CGI.pm 
:function call in a here-doc, as follows:
:
:print <<ZZZ;
:help me $query->param("WHO") please
:ZZZ

    $ man perlfaq4
    ...
       How do I expand function calls in a string?

Without the manpages (which include the FAQs), Perl is
too hard to use.  With them, it is too easy.

--tom
-- 
	Tom Christiansen	tchrist@jhereg.perl.com

    In general, they do what you want, unless you want consistency.
            --Larry Wall in the perl man page


------------------------------

Date: 16 Feb 1998 13:38:14 -0600
From: Erik OShaughnessy <eriko@austin.ibm.com>
Subject: Q: XSUB/Perl Performance (long)
Message-Id: <ufsopjcpcp.fsf@majestic.austin.ibm.com>


I've been messing around with XSUBs trying to improve the performance
of a perl script by attempting to move some of the more expensive
operations ( I/O mostly ) out of perl and into a XSUB interface to a
library I wrote.  I had first written my application in perl, and then
wrote a functionally identical version in C.  When I compared the two
implementations, the perl version was about 18x slower than the C
version.  I was hoping to speed up the perl using XSUBs so I could
retain the flexibility of perl, but I only achieved about a 2x
speedup.

The bones of what I was trying to do is this:

#!/usr/local/bin/perl

use Foo::trace;

$trace = Foo::trace->new($filename);

while( @data = $trace->next_hook() ){
    # munge data here
}


The funtion next_hook() is where I think the most opportunity for
improvement lurks since it get's banged on in a really tight loop.  I
anticipate the average number of iterations thru the loop will be in
the 100's of millions, so I probably need to get this right :)

The library next_hook() function written in C could be decomposed
to look like:

hook *next_hook(trace *trace){
   read( sizeof(int) )      /* hook word */
   read( sizeof(int) * N )  /* hook data */
   read( sizeof(int) )      /* hook thread id */
   read( sizeof(int) )      /* hook timestmap */
}

The number of reads are necessary for various twisted reasons: the
data size is encoded in the first 32bit quantity, the hook may or may
not have a thread id and may or may not be timestamped.  The penalty
for this might be avoided by buffering a page at a time and reading
out of the buffer, but I guess I was/am lazy.

The first XSUB I wrote for next_hook() looks like:

void
next_hook(self)
	trace *self;
	PREINIT:
	hook hook;
	PPCODE:
	if( get_hook(self,&hook) != (hook *)NULL ){
	  XPUSHs(sv_2mortal(newSViv(hook.id)));
	  XPUSHs(sv_2mortal(newSViv(hook.type)));
	  XPUSHs(sv_2mortal(newSViv(hook.hkdata)));
	  XPUSHs(sv_2mortal(newSVpv((char *)hook.data,sizeof(int)*hook.dlen)));
	  XPUSHs(sv_2mortal(newSViv(hook.tid)));
	  XPUSHs(sv_2mortal(newSVnv(self->elapsed_seconds)));
	  XPUSHs(sv_2mortal(newSViv(self->delta_nanos)));
	}

I realize that there are XPUSH[inp] functions, but when I tried to
call them with in the PPCODE section, they resulted in runtime errors
(segfaults).  To get around that it seemed I would need to make new
SV's every time, mortalize them, and push them onto the return stack.
This is where I suspect the first candidate for speedup lurks.  If I
could discover how to avoid the sv_2mortal(newSV*()) calls, I think I
could see some real speed up.

The next XSUB I wrote returned a reference to an array in hopes that
might give me alittle more speed up if it was the call signature that
was slowing down the script.

hook *
next_hook_ref(self)
	trace *self;
	PREINIT:
	hook hook;
	CODE:
	RETVAL = (hook *)safemalloc(sizeof(hook));
	if( get_hook(self,RETVAL) == (hook *)NULL )
	  XSRETURN_UNDEF;
	RETVAL->elapsed_ts = self->elapsed_seconds;
	RETVAL->timestamp = self->delta_nanos;
	OUTPUT:
	RETVAL

I added a typemap entry for hook *, mapping it to T_PACKED and
providing the following support function for packing the hook
structure into an array ( the function was stolen and remunged from
Dean Roehrich's XSUB cookbook B, Struct2 example ):

void
XS_pack_hookPtr(SV *st,hook *hook){
	AV *av;
	SV *sv;
	int i = 0;

	if( hook != (hook *)NULL ){
	  av = newAV();
	  av_store(av,i++,newSViv(hook->id));               /* 0 */
	  av_store(av,i++,newSViv(hook->type));             /* 1 */
	  av_store(av,i++,newSViv(hook->hkdata));           /* 2 */
	  av_store(av,i++,newSVpv(hook->data,hook->dlen));  /* 3 */
	  av_store(av,i++,newSViv(hook->tid));              /* 4 */
	  av_store(av,i++,newSVnv(hook->elapsed_ts));       /* 5 */
	  av_store(av,i++,newSViv(hook->timestamp));        /* 6 */
	  sv = newSVrv( st, NULL );	/* upgrade stack SV to an RV */
	  SvREFCNT_dec( sv );	        /* discard */
	  SvRV( st ) = (SV*)av;	        /* make stack RV point at our AV */
	}
	else{
	  sv = newSVrv( st, NULL );	   /* upgrade stack SV to an RV */
	  SvREFCNT_dec( sv );	           /* discard */
	  SvRV( st ) = newSVsv(&sv_undef); /* make stack RV point at our AV */
	}
}

Again, there are lots of calls to newSV* which my gut tells me is
probably expensive since it probably involves malloc.  The perl
profiler I used on the code only provided subroutine granularity, so
my gut was all I had to go on :)

The difference in performance between the two functions ( one
returning an array and the other returning an array reference ) was
negligble, so I'm pretty sure that there's not much opportunity for
improvement here.  I also dislike the interface you get when returning
an array reference, it just seems less straight forward than returning
the array itself ( regardless of the efficiency of returning the
reference ).

What I'm hoping for is some insight on how to avoid calling newSV* so
much in the XSUB, or maybe some other techniques that might achieve
the same results of what I'm trying to do.

If you made this far thru my post, Thank you!

regards,
ejo

-- 
Erik O'Shaughnessy:eriko at austin.ibm.com:[838|678]-2622:bldg 902/2D014
Performance Tool Development Team:Division Formerly Known As RS/6000:IBM



------------------------------

Date: 15 Feb 1998 09:29:09 GMT
From: Eli the Bearded <*@qz.to>
Subject: Re: regexp: /^[800|888]/ vs. /^8[0{2}|8{2}]/
Message-Id: <qz$9802141709@qz.little-neck.ny.us>

Alan Schwartz <alansz@araw.mede.uic.edu> wrote:
> Fritz Knack <fritz.knack@POPULUS.net> writes:
> >For a report I've written, I'm trying to determine if a given phone
> >number is an 800-class number, i.e., it begins with 800 or 888.
> I got curious, reading this, about whether there was a difference
> in performance between (800|888), 8(00|88), and 8[08]{2}, along with
> versions using (?: instead of (.

Yes there is. "8[08]{2}" is wrong, by the way. 808 is not an 800-class
area code. I don't think 880 is in use (yet) but it is unlikely to be
either.

> Here's an informal test program:
> 
> #!/usr/local/bin/perl

Where is your -w?

> $pat = $ARGV[0];
> # Do this 1000 times:
> foreach $run (1..1000) {

Argh! "use Benchmark;" please.

>                       user process time       system time
> '^8(?:00|88)'         148.7                   0.7
> '^8(00|88)'           148.7                   0.9
> '^(800|888)'          170.3                   0.4
> '^(?:800|888)'        173.6                   0.4
> '^8[08]{2}'           146.9                   0.3
> 
> As might be expected, patterns which require an '8' at the front
> explicitly are quickest -- that can be checked without dealing
> with the alternation or character classes. Interesting to me was:

Yes.

> (1) The interpreter didn't require more time when using ( than (?:.
>     Perhaps it interprets them to the same thing if it notices that 
>     you never use $1?

Sounds very likely.

> (2) ^8[08]{2} is slightly faster than ^8(?:00|88). I think one of the
>     ORA Perl books (camel?) mentions that alternation is relatively
>     slow, but both seemed to do pretty well here. This is probably a 
>     tribute to the pattern-match compiler, which may again have compiled
>     them to very similar patterns.

It probably got optimized to ^8[08][08] which would be pretty fast. You
missed at least one possibility though: "^8([08])\1". That one is not
likely to be fast, but:

#!/usr/bin/perl -w
use Benchmark;

   timethese(400000, {
       '^8([08])\1' => sub { my $num = int(rand() * 900 + 100);
                             /^8([08])\1/;
                           },
       '^8(?:00|88)' => sub { my $num = int(rand() * 900 + 100);
                             /^8(?:00|88)/;
                           },
       '^8(00|88)' => sub { my $num = int(rand() * 900 + 100);
                             /^8(00|88)/;
                           },
       '^(800|888)' => sub { my $num = int(rand() * 900 + 100);
                             /^(800|888)/;
                           },
       '^(?:800|888)' => sub { my $num = int(rand() * 900 + 100);
                             /^(?:800|888)/;
                           }
    });

my $num = defined($1)?1:0; # make sure $1 is set by the above code

__END__

:r! perl -x %
Benchmark: timing 400000 iterations of ^(800|888), ^(?:800|888), ^8(00|88),
	^8(?:00|88), ^8([08])\1...
^(800|888): 14 secs (13.17 usr  0.59 sys = 13.76 cpu)
^(?:800|888): 17 secs (14.89 usr  1.01 sys = 15.90 cpu)
 ^8(00|88): 11 secs ( 9.59 usr  0.66 sys = 10.25 cpu)
^8(?:00|88): 12 secs ( 9.92 usr  0.60 sys = 10.52 cpu)
^8([08])\1: 10 secs ( 9.92 usr  0.50 sys = 10.42 cpu)


Hmmm. Not what I expected really.

Elijah
------
starting to have fun with benchmarks


------------------------------

Date: 15 Feb 1998 20:43:33 GMT
From: neutron@fc.hp.com (Jack Applin)
Subject: Re: regexp: /^[800|888]/ vs. /^8[0{2}|8{2}]/
Message-Id: <6c7k1l$jq@fcnews.fc.hp.com>

Fritz Knack wrote:

> 	if ($phone =~ /^[800|888]/) {

You know, it wouldn't be so bad if -w were to generate a warning in this case,
something like:

	Duplicate character '8' found in character class at line 1.
	Duplicate character '0' found in character class at line 1.


				-Jack Applin
				 neutron@fc.hp.com
				 http://www.geocities.com/HotSprings/6789/


------------------------------

Date: 15 Feb 1998 12:26:49 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: regexp: /^[800|888]/ vs. /^8[0{2}|8{2}]/
Message-Id: <6c6mu9$bhf$1@client2.news.psi.net>

Eli the Bearded (*@qz.to) wrote on 1629 September 1993 in
<URL: news:qz$9802141709@qz.little-neck.ny.us>:
++ Alan Schwartz <alansz@araw.mede.uic.edu> wrote:
++ > Fritz Knack <fritz.knack@POPULUS.net> writes:
++ > >For a report I've written, I'm trying to determine if a given phone
++ > >number is an 800-class number, i.e., it begins with 800 or 888.
++ > I got curious, reading this, about whether there was a difference
++ > in performance between (800|888), 8(00|88), and 8[08]{2}, along with
++ > versions using (?: instead of (.
++ 
++ Yes there is. "8[08]{2}" is wrong, by the way. 808 is not an 800-class
++ area code. I don't think 880 is in use (yet) but it is unlikely to be
++ either.
++ 
++ > Here's an informal test program:
++ > 
++ > #!/usr/local/bin/perl
++ 
++ Where is your -w?
++ 
++ > $pat = $ARGV[0];
++ > # Do this 1000 times:
++ > foreach $run (1..1000) {
++ 
++ Argh! "use Benchmark;" please.
++ 
++ >                       user process time       system time
++ > '^8(?:00|88)'         148.7                   0.7
++ > '^8(00|88)'           148.7                   0.9
++ > '^(800|888)'          170.3                   0.4
++ > '^(?:800|888)'        173.6                   0.4
++ > '^8[08]{2}'           146.9                   0.3
++ > 
++ > As might be expected, patterns which require an '8' at the front
++ > explicitly are quickest -- that can be checked without dealing
++ > with the alternation or character classes. Interesting to me was:
++ 
++ Yes.
++ 
++ > (1) The interpreter didn't require more time when using ( than (?:.
++ >     Perhaps it interprets them to the same thing if it notices that 
++ >     you never use $1?
++ 
++ Sounds very likely.
++ 
++ > (2) ^8[08]{2} is slightly faster than ^8(?:00|88). I think one of the
++ >     ORA Perl books (camel?) mentions that alternation is relatively
++ >     slow, but both seemed to do pretty well here. This is probably a 
++ >     tribute to the pattern-match compiler, which may again have compiled
++ >     them to very similar patterns.
++ 
++ It probably got optimized to ^8[08][08] which would be pretty fast. You
++ missed at least one possibility though: "^8([08])\1". That one is not
++ likely to be fast, but:
++ 
++ #!/usr/bin/perl -w
++ use Benchmark;
++ 
++    timethese(400000, {
++        '^8([08])\1' => sub { my $num = int(rand() * 900 + 100);
++                              /^8([08])\1/;
++                            },
++        '^8(?:00|88)' => sub { my $num = int(rand() * 900 + 100);
++                              /^8(?:00|88)/;
++                            },
++        '^8(00|88)' => sub { my $num = int(rand() * 900 + 100);
++                              /^8(00|88)/;
++                            },
++        '^(800|888)' => sub { my $num = int(rand() * 900 + 100);
++                              /^(800|888)/;
++                            },
++        '^(?:800|888)' => sub { my $num = int(rand() * 900 + 100);
++                              /^(?:800|888)/;
++                            }
++     });
++ 
++ my $num = defined($1)?1:0; # make sure $1 is set by the above code
++ 

It's unclear to me what you are trying to show. The assignment to
$num seems pretty useless to me, after all, you aren't using $num
anywhere. Furthermore, if you did, you wouldn't apply the regex to the
same dataset. Now you are matching against $_, which gets clobbered
by Benchmark.

As for the last line, the slowdown due to backtracking is determined
by the existance of parens, not the occurance of $1 in your code, if
I understand the documentation correctly.

Here's my version, that shows that anchoring the 8 makes a big
difference:

#!/usr/local/bin/perl -w

use strict;
use Benchmark;

use vars qw /@numbers/;


@numbers = (100 .. 999);

timethese 10000, [
    map {$_ => "for my \$reg (\@numbers) {\$reg =~ /$_/}"}
         qw /^8([08])\1 ^8(?:00|88) ^8(00|88) ^(800|888) ^(?:800|888)/
];

__END__

Benchmark: timing 10000 iterations of ^8([08])\1, ^8(?:00|88), ^8(00|88), ^(800|888), ^(?:800|888)...
^8([08])\1: 79 secs (73.46 usr  0.01 sys = 73.47 cpu)
^8(?:00|88): 79 secs (74.47 usr  0.00 sys = 74.47 cpu)
^8(00|88): 81 secs (80.19 usr  0.00 sys = 80.19 cpu)
^(800|888): 155 secs (148.73 usr  0.00 sys = 148.73 cpu)
^(?:800|888): 150 secs (145.85 usr  0.02 sys = 145.87 cpu)



Abigail
-- 
perl -wleprint -eqq-@{[ -eqw+ -eJust -eanother -ePerl -eHacker -e+]}-


------------------------------

Date: 15 Feb 1998 17:07:47 GMT
From: Eli the Bearded <*@qz.to>
Subject: Re: regexp: /^[800|888]/ vs. /^8[0{2}|8{2}]/
Message-Id: <eli$9802151207@qz.little-neck.ny.us>

Abigail <abigail@fnx.com> wrote:
> Eli the Bearded (*@qz.to) wrote on 1629 September 1993 in
> <URL: news:qz$9802141709@qz.little-neck.ny.us>:
[lots of stuff I probably shouldn't have]
> It's unclear to me what you are trying to show. The assignment to

That I should not come in at 3am and finish a post I started earlier
I guess. Oh well.

Elijah
------
nothing witty here


------------------------------

Date: 15 Feb 1998 20:35:06 GMT
From: dannyman <dannyman@arh0300.urh.uiuc.edu>
Subject: Re: RFC about "Matt's Script Archive"
Message-Id: <6c7jhq$f4q$8@vixen.cso.uiuc.edu>

Frank <FHeasley@chemistry.com> wrote:

> Why should the perl wizards here pass out free programs while everyone
> else is making money on them?  Why shouldn't people who understand the
> pitfalls complain about the bad code that's being passed around?

> My only "complaint" is actually a suggestion:  the guys who know how
> to do it right should make it very clear that they are offering to do
> it in return for fair compensation.

I might make a humble suggestion that giving it away for free is something of
a moral benefit after you've been paid by private enterprise to do the dirty
work of writing it and setting it up for them in the first place.

To hear Matt tell it, he gets lots of offers for work or even just offers of
compensation for consulting as to how to deploy his scripts and whatnot. As
for them being rather Archaic buggers - put up or shut up. Matt says he built
the place for fun, when he was younger, learning Perl and all. No, they're
not pretty, but they're there and they get the job done well enough.

danny

-- 
  //Dan   -=-     This message brought to you by djhoward@uiuc.edu    -=-
\\/yori   -=-    Information - http://www.uiuc.edu/ph/www/djhoward/   -=-
aiokomete -=-   Our Honored Symbol deserves an Honorable Retirement


------------------------------

Date: Sun, 15 Feb 1998 15:24:10 GMT
From: bart.mediamind@tornado.be (Bart Lateur)
Subject: Re: RFC about "Matt's Script Archive"
Message-Id: <34edf1b3.8810684@news.tornado.be>

Eli the Bearded <*@qz.to> wrote:

>Hell I've complained about free perl code that was written terribly,
>and my typical solution has been to patch or rewrite it and release
>my version.

Yes! That's the spirit! 

Isn't it just a bit remarkable that many Perl guru's on this newgroup
just complain about the state of Matt's scripts, and nobody volunteers
to make a better version?

BTW. I will not easily volunteer to donate MY Perl code to the world. I
won't risk it. I wouldn't want to be in Matt's shoes.

	Bart.


------------------------------

Date: 15 Feb 1998 15:53:16 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: RFC about "Matt's Script Archive"
Message-Id: <6c731c$dm@fridge.shore.net>

Bart Lateur (bart.mediamind@tornado.be) wrote:

: BTW. I will not easily volunteer to donate MY Perl code to the world. I
: won't risk it. I wouldn't want to be in Matt's shoes.

What do you mean?  

People might complain, and they might not be all that pleasant about
it, but you can guarantee that the end result will something (that you
did with their help).  Even when I've written something very stupid
and have been corrected (perhaps in an unfriendly manner), I've fixed
things and moved on.  You can too.

You're making really horrendous assumptions here.

--
Nathan V. Patwardhan


------------------------------

Date: Sun, 15 Feb 1998 20:35:52 GMT
From: bart.mediamind@tornado.be (Bart Lateur)
Subject: Re: RFC about "Matt's Script Archive"
Message-Id: <34e844bf.1659284@news.tornado.be>

Tom Christiansen <tchrist@mox.perl.com> wrote:

>In comp.lang.perl.misc, bart.mediamind@tornado.be (Bart Lateur) writes:
>:Isn't it just a bit remarkable that many Perl guru's on this newgroup
>:just complain about the state of Matt's scripts, and nobody volunteers
>:to make a better version?
>
>Beach.  Beggars.  Finite Time.  Responsibility.  Chemists.

I didn't actually mean you, Tom. In fact, I would by far prefer it (for
example; I won't force you) if you would write some more articles in the
"far more than you ever wanted to know" series. That might have been the
most interesting Perl related web pages I've ever read, together with
Randal's Webtechniques.

But I have noticed quite a few slamming posts about Matt's scripts in
this newsgroup in the last few weeks alone. Now if only some of these
people would actually (A) contact Matt about it (I'm pretty convinced he
doesn't read this newsgroup), and/or (B) spend the time and energy into
patching the code instead of just writing nasty newsgroup articles about
it, this would have been fixed a long time ago.

Furthermore, Tom, if people contact you telling you that you HAVE to
help them, you can still tell them you don't have to, unless they pay
you. After all, you ARE a computer professional.

A company I worked for, asked a translation bureau how to write
"(10.5%)" in Arabic. We got a fax back, with the answer, plus a bill of
around 50$. Really.

	Bart.


------------------------------

Date: 15 Feb 1998 20:52:11 GMT
From: "Eric Umehara" <momiji@slip.net>
Subject: Running Perl
Message-Id: <01bd3a54$246b0820$5b8898d1@default>

I can't figure out how to test my perl script. Can you help?

I downloaded a perl interpeter PW32i315 and ran the uncopresser and then
ran the batch file with no problems. I then wrote a small Hello World perl
script saved it in the bin directory and even after I tried typing the name
including the extension .pl it woudn't run. I used the dos PERL program in
the C:\Perl\bin directory and copied the script it into that. It didn't
work I then tried some BASIC commands such as run. How do I test my
script??

Thanks
Momiji@Slip.Net


------------------------------

Date: 15 Feb 1998 16:58:23 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Searching a file for a word.
Message-Id: <6c76rf$r25$1@csnews.cs.colorado.edu>

 [courtesy cc of this posting sent to cited author via email]

In comp.lang.perl.misc, The Tufgars <tufgar@golden.net> writes:
:    I was wondering how I would go about searching a file for a specific
:word and when it is found the program would read the next 20 lines in
:the file into an array.  Each element in the array would hold one line.

This seems extremely easy.  Which thing were you having troubles with:

    * opening a file
    * reading a line at a time
    * searching a line for string
    * storing a line in an array

Personally, I find that 'grep -A 20 word file' works fine.  That 
requires GNU grep, however.

--tom
-- 
	Tom Christiansen	tchrist@jhereg.perl.com


Ask Ken.  He hates Everything.


------------------------------

Date: 15 Feb 1998 23:55:33 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Sort help please!
Message-Id: <6c7v9l$ob4$3@marina.cinenet.net>

Joseph N. Hall (joseph@5sigma.com) wrote:
: If you use my new Sort::Fields module, you don't have to worry
: about what a Schwartzian Transform (that map sort map thing)
: is, or how it works.

Yes, but this hardly improves the soul, now, does it? :)

---------------------------------------------------------------------
   |   Craig Berry - cberry@cinenet.net
 --*--    Home Page: http://www.cinenet.net/users/cberry/home.html
   |      Member of The HTML Writers Guild: http://www.hwg.org/   
       "Every man and every woman is a star."


------------------------------

Date: 15 Feb 1998 20:35:06 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Testing integer
Message-Id: <6c7jhq$8q2$1@marina.cinenet.net>

Andy Brezing (brezing@gia.rwth-aachen.de) wrote:
: I'm a Perl beginner and need some some help in the distinction of data
: types.
: 
: Question: How can I test a variable whether it's an integer or not, 
: the variable value could be any data-type (string,number,list ...)
: 
: I've tried to do it this way, but it didn't work:
: 
:      print "$i not an number \n" unless /^\d+$i/;

What's $i doing inside the pattern?  You probably mean

  print "$i not an integer\n" unless $i =~ /^\d+$/;

Note that I've added an end-anchor to make sure $i is *all* digits and 
nothing but.

Even easier would be

  print "..." if $i =~ /\D/;

-- that is, if there are any non-digits in the string.  The one problem 
with this form is that it lets through empty strings as being 'integers'.

---------------------------------------------------------------------
   |   Craig Berry - cberry@cinenet.net
 --*--    Home Page: http://www.cinenet.net/users/cberry/home.html
   |      Member of The HTML Writers Guild: http://www.hwg.org/   
       "Every man and every woman is a star."


------------------------------

Date: 15 Feb 1998 20:45:23 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Testing integer
Message-Id: <6c7k53$8q2$2@marina.cinenet.net>

Joseph N. Hall (joseph@5sigma.com) wrote:
: int($a) == $a, perhaps

Tests true for $a = 'I am not an integer.'

---------------------------------------------------------------------
   |   Craig Berry - cberry@cinenet.net
 --*--    Home Page: http://www.cinenet.net/users/cberry/home.html
   |      Member of The HTML Writers Guild: http://www.hwg.org/   
       "Every man and every woman is a star."


------------------------------

Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 8 Mar 97)
Message-Id: <null>


Administrivia:

The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc.  For subscription or unsubscription requests, send
the single line:

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.

The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.

The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.

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 V8 Issue 1905
**************************************

home help back first fref pref prev next nref lref last post