[8066] in Perl-Users-Digest
resending truncated digests issues 1680-1683
daemon@ATHENA.MIT.EDU (Perl-Users-Request@ruby.OCE.ORST.E)
Tue Jan 20 20:17:24 1998
Date: Tue, 20 Jan 98 17:11:09 -0800
From: Perl-Users-Request@ruby.OCE.ORST.EDU
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Tue, 20 Jan 1998 Volume: 8 Number: 1682
Today's topics:
Re: REGEXP: Does it need optimization? (Greg Bacon)
Simple example of Select needed please (Paul Ryder)
Re: source into binary code <rra@stanford.edu>
Re: space searching? (Emile Heyns)
Re: space searching? <jmatocha@cs.ua.edu>
Re: space searching? <westxga@ptsc.slg.eds.com>
Re: space searching? (Tad McClellan)
Re: Switch statement in Perl-5??? (Andrew M. Langmead)
trying to install FCGI(problem with sfio) <kinlam@mec.cuny.edu>
What am I missing here? (Brandi Weed)
Re: What am I missing here? (brian d foy)
Re: Why shift ? (brian d foy)
Re: Why shift ? <doug@tc.net>
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 20 Jan 1998 16:41:52 GMT
From: gbacon@adtran.com (Greg Bacon)
To: Vladimir Alexiev <vladimir@cs.ualberta.ca>
Subject: Re: REGEXP: Does it need optimization?
Message-Id: <6a2k4g$m06$3@info.uah.edu>
[Posted and mailed]
In article <om67nf3bwy.fsf@tees.cs.ualberta.ca>,
Vladimir Alexiev <vladimir@cs.ualberta.ca> writes:
: In article <6a0jna$20k$5@info.uah.edu> gbacon@adtran.com (Greg Bacon) writes:
: > In general, cautious quantifiers produce slower matching regoxen.
:
: Care to explain this? I just found out that in the following perversion:
: perl -le 'print "Prime" if (1 x shift) !~ /^1?$|^(11+?)\1+$/'
: removing the cautious quantifier here ^ causes it
: to take 6x more user time, but 2.5 times less system time.
Keep in mind that /.+/ and /.+?/ are not necessarily equivalent. I
found jfriedl's diagrams at the Perl Conference most enlightening.
Consider the regoxen /a.*b/ and /a.*?b/. They are both trying to do
the same thing:
.---.
.---> | . | ->--.
| `---' |
.---. | | .---.
---> | a | ---F------->-------)---> | b | ---> Match!
`---' ^ | `---'
| |
`-------<-------'
The only difference between the greedy and the cautious regular
expression is that at each time control comes to the fork in the path
(the point marked `F'), the greedy prefers to try to match /./ while the
cautious attempts to skip matching /./ (and go on to try to match /b/).
Greedy vs. cautious: it's all a matter of preference. :-)
My guess is, with Abigail's primality test, the regex engine has to
do much more backtracking with the greedy version, but the cautious
version is an optimization for finding the critical point toward the
front or in the middle of the run of 1s instead of near the end.
Maybe Jeffrey or Elijah can offer a better explanation.
Those of us who've read GEB might prefer to see
perl -le 'print "Prime" if "S" . (0 x shift) !~ /^S?0?$|^S(00+?)\1+$/
Hope this helps,
Greg
--
open G,"|gzip -dc";$_=<<EOF;s/([0-9a-f]+)/print G pack"h*",$1/eg
f1b88000b620f22320303fa2d2e21584ccbcf29c84d2258084
d2ac158c84c4ece4d22d1000118a8d5491000000
EOF
------------------------------
Date: Tue, 20 Jan 1998 15:47:05 GMT
From: paul@f1world.com (Paul Ryder)
Subject: Simple example of Select needed please
Message-Id: <34c4c69b.23512178@news.u-net.com>
Hi,
Could someone just outline a simple example of how select works.
Into the perl script will be coming the following :
A Socket Connection
Keyboard STDIN
How can i use select to listen for both? no need to go into the
listen/socket code, i just need to see how select works ..
Thanks in advance!
Regards
Paul.
_________________________________________________
Paul Ryder http://www.f1world.com
paul@pry.u-net.com ICQ : 262573
paul@f1world.com
paul@quake2.com
------------------------------
Date: 20 Jan 1998 06:41:29 -0800
From: Russ Allbery <rra@stanford.edu>
Subject: Re: source into binary code
Message-Id: <m390sbb42u.fsf@windlord.Stanford.EDU>
John Stanley <stanley@skyking.OCE.ORST.EDU> writes:
> If you don't believe that what I suggested can be a factor, then explain
> 1) creeping featuritis, which shows that "does more than foo" is
> generally desirable,
The fact that people buy things for a particular feature does not
necessarily indicate that the feature is an improvement in the product,
even from the perspective of those people. There are mass psychology
factors that enter the equation when things hit the marketing department
that you have to take into account.
Some people have defined advertising as the process of convincing people
to buy things they neither want nor need. I think that's going a bit far,
but there's an element of truth in it as well.
(This is not to imply that all advertisement is aimed that way, that
everyone can be fooled in that fashion, or that popularity is completely
unrelated to quality. It's simply an observation that popularity does not
necessarily imply quality, even to those who are making up the statistic
of popularity.)
> 2) Cygnus Software, which will sell you support for gcc -- which, if you
> might notice, changes gcc not a whit
I'm afraid this is not correct. Cygnus feeds their mods back into the gcc
development tree.
> Hmmmm. Maybe. Maybe not. But when I have a perl question, there is
> nobody to call to say "what's the answer".
Sure there is. There are people who sell commercial Perl support. Many
of them post to this newsgroup. With free software, the source of the
software and the source of the support are simply divided.
> That's called "support", and it is a reason that people will pay for
> software.
They can buy it directly.
> I didn't say it was. I was giving examples of why people might pay for
> something they could get for free, and pointing out that they might not
> be getting everything when they chose the free option.
I agree with that general point.
--
#!/usr/bin/perl -- Russ Allbery, Just Another Perl Hacker
$^=q;@!>~|{>krw>yn{u<$$<[~||<Juukn{=,<S~|}<Jwx}qn{<Yn{u<Qjltn{ > 0gFzD gD,
00Fz, 0,,( 0hF 0g)F/=, 0> "L$/GEIFewe{,$/ 0C$~> "@=,m,|,(e 0.), 01,pnn,y{
rw} >;,$0=q,$,,($_=$^)=~y,$/ C-~><@=\n\r,-~$:-u/ #y,d,s,(\$.),$1,gee,print
------------------------------
Date: Tue, 20 Jan 1998 13:11:47 GMT
From: qqehe@st5-oa6.oce.nl (Emile Heyns)
Subject: Re: space searching?
Message-Id: <En33Bn.8yJ@oce.nl>
On Tue, 20 Jan 1998 11:34:53 GMT, Stephen Howe wrote:
:I have a line saying
:To: stephen@solamnia.demon.co.uk, stephen@bcl.com, daryn@blahblah.com
:
:etc..
:I need to know how to figure out the user associated with ONLY the
:bcl.com site...
# Fill $line with your To: line any which way
$line = "To: stephen\@solamnia.demon.co.uk, stephen\@bcl.com, "
$line += "daryn\@blahblah.com";
# Gimme that ol' perl magic...
@bclusers = grep (/\@bcl\.com/, split(/,?\s+/, $line));
@bclusers now holds an array of all users of domain bcl.com
See perlfunc manpage for descriptions of grep and split
--
Emile
A real person has two reasons for doing anything ... a good reason and
the real reason.
------------------------------
Date: Tue, 20 Jan 1998 09:06:57 -0600
From: Jeff Matocha <jmatocha@cs.ua.edu>
Subject: Re: space searching?
Message-Id: <34C4BD90.7F2A@cs.ua.edu>
Stephen Howe wrote:
> I have a line saying
> To: stephen@solamnia.demon.co.uk, stephen@bcl.com, daryn@blahblah.com
>
> etc..
> I need to know how to figure out the user associated with ONLY the
> bcl.com site...
Hey,
I'm a novice at perl, but I'd try searching for
/ ([a-zA-Z0-9\.\-]*)\@bcl.com/
^ note the space
This should (I hope :) put their userid into $1.
Jeff
------------------------------
Date: Tue, 20 Jan 1998 10:06:21 +0000
From: Glenn West <westxga@ptsc.slg.eds.com>
Subject: Re: space searching?
Message-Id: <34C4771D.2D40@ptsc.slg.eds.com>
Stephen Howe wrote:
>
> Dear guys...
>
> I've got a desperate need to know how to do this so i'm begging for
> help..
>
> I have a line saying
> To: stephen@solamnia.demon.co.uk, stephen@bcl.com, daryn@blahblah.com
>
> etc..
> I need to know how to figure out the user associated with ONLY the
> bcl.com site...
>
> If I search the string for bcl.com, I can get the index of the
> bcl.com... then I need to backtrack, searching for a blank space at
> every step, then substr from the position of the whitespace, to the
> position of the @.
>
> Any ideas... please?
>
> Thank you HEAPS and HEAPS... I really need this help :(
>
> Stephen Howe
$_='To: stephen@solamnia.demon.co.uk, stephen@bcl.com,
daryn@blahblah.com';
/\s(\w+)\@bcl\.com,/;
print "$1\n";
------------------------------
Date: Tue, 20 Jan 1998 09:25:07 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: space searching?
Message-Id: <jkf2a6.net.ln@localhost>
Jeff Matocha (jmatocha@cs.ua.edu) wrote:
: Stephen Howe wrote:
: > I have a line saying
: > To: stephen@solamnia.demon.co.uk, stephen@bcl.com, daryn@blahblah.com
: >
: > etc..
: > I need to know how to figure out the user associated with ONLY the
: > bcl.com site...
: I'm a novice at perl, but I'd try searching for
: / ([a-zA-Z0-9\.\-]*)\@bcl.com/
None of the other followups will correctly recognize
'stephen@machine.bcl.com', because they all rely on
a literal '@' char (of course my followup could easily
be broken too...)
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Tue, 20 Jan 1998 15:04:50 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: Switch statement in Perl-5???
Message-Id: <En38K2.84u@world.std.com>
"David Mohorn" <david.mohorn@sourcebbs.com> writes:
>What is perlsyn? I am using Perl for Win32. I don't have Perl for UNIX
>installed anyplace.
Below is a slightly edited copy of an article I posted about a month
ago.
Perl comes with a lot of free documentation. They are often called
"man pages" because of the language's unix heritage. The way of
accessing this documentation depends on the operating system that you
use, but in most cases it seems that the people who work on perl on
these various operating systems have gone through great effort to make
this information available in a convenient format.
On Unix, the perl documentation is installed in the common unix manual
format. This documentation is accessed using the "man" command. If you
type "man perl" at a shell prompt, it will show you a list of other
pages divided by content. To access the page with a list of perl
functions, type "man perlfunc".
On Windows 95 and Windows NT, the man pages are converted into HTML
format for you and placed inside the "docs" directory. You can view
them with any web browser. Conveniently enough, Microsoft includes a
web browser with every copy of Windows 95 it sells.
On the Macintosh, Matthias Neeracher made a special documentation
viewing program called "Shuck", (the reason for the name is a bit of
an inside joke. Luckily the joke has not prevented from not being able
to find the documentation. You can also access the documentation from
within the IDE by going to the help menu.)
On the OS/2 port, Ilya Zakharevich converted the documentation into
OS/2's .INF format.
Other people have spent time converting the documentation into the GNU
systems "info" format, Adobe's PDF, and others. You can probably find
them at <URL:http://www.perl.com/CPAN/doc/manual>
If you ever pick up the book called "Programming Perl", which most
people consider the definitive perl reference book, you'll realize
that it is most cases a superset of the documentation that is provided
with perl.
--
Andrew Langmead
------------------------------
Date: Tue, 20 Jan 1998 09:58:06 -0600
From: "kinlam" <kinlam@mec.cuny.edu>
Subject: trying to install FCGI(problem with sfio)
Message-Id: <6a2hrp$g9c$1@news.cuny.edu>
I download a modules(FCGI-0.30) from CPAN. When I try to install it,
It
give an error of "perl isn't compiled with perlio/sfio support. I found out
from the REAME file that come with FCGI module that I have to configure perl
with the following option
'./Configure -Duseperlio -Dusesfio'. So, I did, but I still get the same
error.
I think the C complier I have don't have the neccessary lib(sfio). If
that's the reason,
can anybody know how I can obtain it.(I am using ibm c complier, but if
needed
I can also use a GNU C).
any comments will be greatly appreciated
Kin Lam
E-mail : kinlam@mec.cuny.edu
------------------------------
Date: Tue, 20 Jan 1998 16:32:56 GMT
From: brandi@wheel.dcn.davis.ca.us (Brandi Weed)
Subject: What am I missing here?
Message-Id: <34c4d176.1184064@news.cwnet.com>
To my eyes, this subroutine looks okay, but it always returns true.
Can anybody help me?
sub all_needed_fields {
$missing = 0;
$missing = 1 if (not param('name'));
$missing = 1 if (not param('address'));
$missing = 1 if (not param('city'));
$missing = 1 if (not param('state'));
$missing = 1 if (not param('zipcode'));
$missing = 1 if (not param('email'));
return $missing;
}
--
Brandi Weed
brandi@wheel.dcn.davis.ca.us
http://www.dcn.davis.ca.us/~brandi/
------------------------------
Date: Tue, 20 Jan 1998 11:41:51 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: What am I missing here?
Message-Id: <comdog-ya02408000R2001981141510001@news.panix.com>
Keywords: from just another new york perl hacker
Please read this information on how to choose a good subject for a post:
<URL:http://www.perl.com/CPAN/authors/Dean_Roehrich/subjects.post>
In article <34c4d176.1184064@news.cwnet.com>, brandi@wheel.dcn.davis.ca.us (Brandi Weed) posted:
>To my eyes, this subroutine looks okay, but it always returns true.
>Can anybody help me?
>
>sub all_needed_fields {
> $missing = 0;
> $missing = 1 if (not param('name'));
> $missing = 1 if (not param('address'));
> $missing = 1 if (not param('city'));
> $missing = 1 if (not param('state'));
> $missing = 1 if (not param('zipcode'));
> $missing = 1 if (not param('email'));
> return $missing;
>}
what's param()? wouldn't you like to use a short circuit operator
so you don't always have to do every test? a construction like
if( $this and $that and $the_other_thing )
will fail at the first test that is not true, and will not need
to evaluate the others.
good luck :)
--
brian d foy <comdog@computerdog.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
Comprehensive Perl Archive Network (CPAN) <URL:http://www.perl.com>
------------------------------
Date: Tue, 20 Jan 1998 11:17:26 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: Why shift ?
Message-Id: <comdog-ya02408000R2001981117260001@news.panix.com>
Keywords: from just another new york perl hacker
In article <34C4B3A9.41C6@bvr.co.il>, Eyal <eyalb@bvr.co.il> posted:
>sub get_rec {
> my $fh = shift;
> return scalar <$fh>;
>}
>
>why use shift ?
to remove the first value from @_ and assign it to $fh. perhaps
you wanted a more philosophical justification though?
--
brian d foy <comdog@computerdog.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
Comprehensive Perl Archive Network (CPAN) <URL:http://www.perl.com>
------------------------------
Date: 20 Jan 1998 11:13:49 -0500
From: Douglas McNaught <doug@tc.net>
Subject: Re: Why shift ?
Message-Id: <m21zy3gm2q.fsf@ono.tc.net>
Eyal <eyalb@bvr.co.il> writes:
> from the Programming Perl book (P. 118) :
>
> $rec = get_rec(\*STDIN);
>
> sub get_rec {
> my $fh = shift;
> return scalar <$fh>;
> }
>
> why use shift ?
Er... Because it works and it's easy to type (as well as being a
common idiom from the shell programming world)?
-Doug
--
sub g{my$i=index$t,$_[0];($i%5,int$i/5)}sub h{substr$t,5*$_[1]+$_[0],1}sub n{(
$_[0]+4)%5}$t='encryptabdfghjklmoqsuvwxz';$c='fxmdwbcmagnyubnyquohyhny';while(
$c=~s/(.)(.)//){($w,$x)=g$1;($y,$z)=g$2;$w==$y&&($p.=h($w,n$x).h($y,n$z))or$x==
$z&&($p.=h(n$w,$x).h(n$y,$z))or($p.=h($y,$x).h($w,$z))}$p=~y/x/ /;print$p,"\n";
------------------------------
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 1682
**************************************