[12671] in Perl-Users-Digest
Perl-Users Digest, Issue: 80 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jul 8 15:17:22 1999
Date: Thu, 8 Jul 1999 12:10:14 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Thu, 8 Jul 1999 Volume: 9 Number: 80
Today's topics:
Re: Pattern match counting (Bart Lateur)
Re: Pattern match counting <scott@nospamplease.cablesoft.com>
Re: Pattern match counting (Greg Bacon)
Re: Pattern match counting <ptimmins@itd.sterling.com>
Re: Pattern match counting (Larry Rosler)
Re: Perl script will not run from cgi-bin (Jim Hutchison)
Re: PERLFUNC: sqrt - square root function <mhc@Eng.Sun.COM>
Problems with Win32::AdminMisc::UserSetMiscAttributes o kalikste@my-deja.com
Re: Question: Good Project? <cassell@mail.cor.epa.gov>
Re: Random Numbers (Larry Rosler)
Re: REMOTE_HOST never gives host... <flavell@mail.cern.ch>
Re: Simple.pm Error <alex@exbook.com>
Re: Time calculations in Perl for Win32 <hannak@kodak.com>
Re: UPS shipping code??? <cassell@mail.cor.epa.gov>
Re: Webpages and Perl-Couple of Questions (Abigail)
Re: Which is better, Perl, Cold Fusion or... (Jim Hutchison)
Digest Administrivia (Last modified: 1 Jul 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 08 Jul 1999 17:38:11 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Pattern match counting
Message-Id: <3784e0d7.160820@news.skynet.be>
David U wrote:
>$example_data = "ALLR : ALLR : ALLR : ALLR : USPA : AMCA : ALLR : USMI :
>USOH : USIL : USNY : AMCA : USME : USMD : USMD : ALLR : USMD : USMD :
>ALLR : USMD : USLA : ALLR : AUST : USAZ : ALLR : USKY : USKY : USNJ :
>USCA : USCA : USCA : ALLR : ALLR : USME : ALLR : USCA : ALLR : USNJ :
>USNJ : USCA : USWI : ALLR : AMCA : ALLR";
>
>How can I count the number of times "ALLR" appears in the $example_data?
Use the //g modifier, Luke.
$howmany = () = $example_data =~ /ALLR/g;
You need a trick to make the pattern match happen in list context,
that's what the "() = " is for. Otherwise, you'll get one match, every
time this statement is called. So this may work too.
$howmany = 0;
$howmany++ while $example_data =~ /ALLR/g;
In fact, it does. BTW the answer is 15.
Bart.
------------------------------
Date: Thu, 8 Jul 1999 13:39:08 -0400
From: "Scott P. Renton" <scott@nospamplease.cablesoft.com>
Subject: Re: Pattern match counting
Message-Id: <7m2npa$mus@news-central.tiac.net>
e-mail cc:'d to poster.
Try this:
$count = 0;
$string = "This is a string of things that is counting the is in this
string";
while ($string =~ /is/gi) {
++$count;
}
print $count
Please keep in mind I threw this together in about a minute, so there's
probably a better way, this just popped into my head.
Scott
David U wrote in message <3784D524.FBC19E35@tidalwave.net>...
>Is there a way to count how many times a pattern has been matched?
>
>I'm trying to see how many times a string contains repetitive bits of
>info --
>
>$example_data = "ALLR : ALLR : ALLR : ALLR : USPA : AMCA : ALLR : USMI :
>USOH : USIL : USNY : AMCA : USME : USMD : USMD : ALLR : USMD : USMD :
>ALLR : USMD : USLA : ALLR : AUST : USAZ : ALLR : USKY : USKY : USNJ :
>USCA : USCA : USCA : ALLR : ALLR : USME : ALLR : USCA : ALLR : USNJ :
>USNJ : USCA : USWI : ALLR : AMCA : ALLR";
>
>How can I count the number of times "ALLR" appears in the $example_data?
>
>I'm guessing it'll look something like --
>
>$count_results =~ (/ALLR/, $example_data);
>
>...but I that doesn't seem to work, of course, when I try to print
>$count_results.
>
>Thanks!
>
>
------------------------------
Date: 8 Jul 1999 17:58:50 GMT
From: gbacon@itsc.uah.edu (Greg Bacon)
Subject: Re: Pattern match counting
Message-Id: <7m2osq$o89$1@info2.uah.edu>
In article <3784D524.FBC19E35@tidalwave.net>,
David U <offwhite@tidalwave.net> writes:
: Is there a way to count how many times a pattern has been matched?
$count = () = $str =~ /PATTERN/g;
Greg
--
Ah, women. They make the highs higher and the lows more frequent.
-- Nietzsche
------------------------------
Date: Thu, 08 Jul 1999 17:53:40 GMT
From: Patrick Timmins <ptimmins@itd.sterling.com>
Subject: Re: Pattern match counting
Message-Id: <7m2oiu$i70$1@nnrp1.deja.com>
In article <3784D524.FBC19E35@tidalwave.net>,
anglochinapino@geocities.com wrote:
> Is there a way to count how many times a pattern has been matched?
A FAQ in perlfaq6 (Regexps) :
How can I print out a word-frequency or line-frequency summary?
$monger{Omaha}[0]
Patrick Timmins
ptimmins@itd.sterling.com
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: Thu, 8 Jul 1999 10:49:25 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Pattern match counting
Message-Id: <MPG.11ee847bf110e817989c74@nntp.hpl.hp.com>
[Posted and a courtesy copy mailed.]
In article <3784D524.FBC19E35@tidalwave.net> on Thu, 08 Jul 1999
12:43:16 -0400, David U <offwhite@tidalwave.net> says...
> Is there a way to count how many times a pattern has been matched?
>
> I'm trying to see how many times a string contains repetitive bits of
> info --
>
> $example_data = "ALLR : ALLR : ALLR : ALLR : USPA : AMCA : ALLR : USMI :
> USOH : USIL : USNY : AMCA : USME : USMD : USMD : ALLR : USMD : USMD :
> ALLR : USMD : USLA : ALLR : AUST : USAZ : ALLR : USKY : USKY : USNJ :
> USCA : USCA : USCA : ALLR : ALLR : USME : ALLR : USCA : ALLR : USNJ :
> USNJ : USCA : USWI : ALLR : AMCA : ALLR";
>
> How can I count the number of times "ALLR" appears in the $example_data?
#!/usr/local/bin/perl -w
use strict;
$_ = "ALLR : ALLR : ALLR : ALLR : USPA : AMCA : ALLR : USMI :
USOH : USIL : USNY : AMCA : USME : USMD : USMD : ALLR : USMD : USMD :
ALLR : USMD : USLA : ALLR : AUST : USAZ : ALLR : USKY : USKY : USNJ :
USCA : USCA : USCA : ALLR : ALLR : USME : ALLR : USCA : ALLR : USNJ :
USNJ : USCA : USWI : ALLR : AMCA : ALLR";
my $count = 0;
++$count while /ALLR/g;
print "$count\n";
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Thu, 08 Jul 1999 17:19:59 GMT
From: jimhutchison@metronet.ca (Jim Hutchison)
Subject: Re: Perl script will not run from cgi-bin
Message-Id: <3784dd26.242403447@news1.cal.metronet.ca>
Don't mean to insult you, but did you try to su to the web process
owner? (nobody in all likelyhood).
I had a similar problem. I su'd to nobody, then ran it from the
command line. The problem became obvious.
On Thu, 8 Jul 1999 10:09:17 -0400, "Keith Lee" <leejk@cat.com> wrote:
>Hey everyone,
> I have a little perl script that runs another program. When this script
>is run from the command line, it works fine, but when executed from the web
>server it fails. At first, the server logs showed that the external program
>I was trying to launch could not find certain libraries. For some reason,
>the web server recognizes all other environment variables but $SHLIB_PATH,
>which is where the location of the library files is defined that my external
>program needs to run. What I tried is to define this vaiable inside the Perl
>script. The error messages in the server log no longer appear, and the
>external program runs, but does not output what is expected. It seems to die
>before it is finished. I am using an Apache web server on a HP-UX machine.
>Can anybody tell me if this a web server problem, or is my Perl bad?
>
>#!/usr/local/perl5/bin/perl -w
>
># define required modules
>use diagnostics;
>
>$new_filename = "aaaa08077.vdi";
>$vdi_filename = "aaaa08077.vdi";
>$tmp_dir = "/demo/web/htdocs/tmp_files";
>
># establish paths
>$oldpath = $ENV{"SHLIB_PATH"};
>$ENV{"SHLIB_PATH"} = "/demo/division/lib/hpux10";
>
># create vpf file
>system("/demo/division/bin/hpux10/vdi2vpf -pb $tmp_dir $vdi_filename");
>
>
------------------------------
Date: 08 Jul 1999 10:59:00 -0700
From: Mike Coffin <mhc@Eng.Sun.COM>
Subject: Re: PERLFUNC: sqrt - square root function
Message-Id: <8p6pv23c9az.fsf@Eng.Sun.COM>
Tom Christiansen <perlfaq-suggestions@perl.com> writes:
>
> DESCRIPTION
> Return the square root of EXPR. If EXPR is omitted, returns square
More precisely, it returns the *non-negative* square root of EXPR.
-mike
------------------------------
Date: Thu, 08 Jul 1999 18:54:45 GMT
From: kalikste@my-deja.com
Subject: Problems with Win32::AdminMisc::UserSetMiscAttributes on remote computers
Message-Id: <7m2s5e$jqr$1@nnrp1.deja.com>
Hey all-
Can't get Win32::AdminMisc::UserSetMiscAttributes to work correctly on
remote computers (AdminMisc is David Roth's great extention of
Win32::NetAdmin). No problem getting this to work when the $Domain
attribute is sent as a null string (defaults to current computer), but
it absolutely won't work on a remote computer or domain.
I have tried "\\\\ComputerName", "ComputerName", "DomainName",
"\\\\DomainName", but to no avail. I can't even specify the local
computer as the domain and have it work- it only works when I send ""
or '' as the $Domain input. I have administrative access on all
machines.
Are there any caveats to using this?
Thanks,
jeff
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: Thu, 08 Jul 1999 11:20:56 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Question: Good Project?
Message-Id: <3784EC08.2A511256@mail.cor.epa.gov>
Chad La Joie wrote:
>
> That idea is so stupid.
> --CK
>
> Jason Stapels wrote:
>
> > Write Windows2001
Helpful hint #763.2:
Before posting to comp.lang.perl.misc, be sure to do this:
use Lingua::Humor;
HTH,
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: Thu, 8 Jul 1999 11:47:27 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Random Numbers
Message-Id: <MPG.11ee921a92212f97989c75@nntp.hpl.hp.com>
[Posted and a courtesy copy mailed.]
In article <7lhjlp$2ro$1@nnrp1.deja.com> on Fri, 02 Jul 1999 05:45:31
GMT, rt_daemon@my-deja.com <rt_daemon@my-deja.com> says...
> How do I make my random numbers to be of 7 Numbers and between 0 and
> 9999999
>
> 0000000 to 9999999
That depends. Will you be satisfied with < ~2**15 different numbers in
that range? If not, read perlfaq4: "Why aren't my random numbers
random?" and follow the suggestons there.
The little program below will demonstrate the problem very clearly. A
quicker way to see it is to do the command `perl -V:randbits`, which
gives 15 on each of the systems I have tried.
#!/usr/local/bin/perl -w
use strict;
@_{map sprintf('%07d', rand 10_000_000) => 1 .. 100_000} = ();
print scalar keys %_, "\n";
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Thu, 8 Jul 1999 19:01:07 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: REMOTE_HOST never gives host...
Message-Id: <Pine.HPP.3.95a.990708185150.8934E-100000@hpplus01.cern.ch>
On Fri, 9 Jul 1999, Brendan Reville wrote:
> $ip_number = "$ENV{'REMOTE_HOST'}";
>
> to grab a visitor's host name.
This is a server configuration question, not a Perl language problem.
As such, you might get better results by checking the documentation for
the server that you use.
> Is there perhaps something peculiar about the server that I'm running
See, you suspected it was a server configuration issue! The Apache
notes give the very wise advice to turn off DNS lookups in general. I
suppose most admins would take this advice, but I don't have statistics.
> Or have I overlooked something?
REMOTE_ADDR , presumably
If you feel you must, then you can look the corresponding name up from
your script. This is where Perl _can_ help, but then it's just a matter
of reading the Perl documentation. Don't forget to allow for the
possibility that the lookup doesn't work.
Be aware, though, that in general the address that you get in
REMOTE_ADDR may not be the address of the actual client, it might be the
address of a web proxy that they're sitting behind.
------------------------------
Date: 8 Jul 1999 18:26:20 GMT
From: "Alex" <alex@exbook.com>
Subject: Re: Simple.pm Error
Message-Id: <01bec96f$6084eeb0$258eb987@il0015jtampc>
I can not use wget or url_get if it is run under Windows Enviroment.
Anyone Can help?
------------------------------
Date: Thu, 08 Jul 1999 13:48:05 -0400
From: Victor Hannak <hannak@kodak.com>
Subject: Re: Time calculations in Perl for Win32
Message-Id: <3784E455.FEEFB284@kodak.com>
A more advanced time question:
Is there a function for Perl Win32 that allows you to determine if a given
time is between certain hours of any day?
Thanks
Victor Hannak wrote:
> Please disregard this post.
>
> I have found a previous post that answers these questions.
>
> Victor Hannak wrote:
>
> > I am trying to create some code that tests the difference between the
> > current time and a previous timestamp. Is there a function for the
> > Win32 version of Perl that does this type of manipulation? Any comments
> > would be helpful.
> >
> > Also, is there a function like wait(5 min) that pauses the execution of
> > a script for a certain amount of time?
> >
> > I could not find either of these in the documentation.
> >
> > Thanks.
------------------------------
Date: Thu, 08 Jul 1999 11:02:59 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: UPS shipping code???
Message-Id: <3784E7D3.DEEEF28B@mail.cor.epa.gov>
David Efflandt wrote:
>
> Have you considered checking out http://www.ups.com/ ?
> They used to have a perl script on their site but I am not sure where to
> find it. They do have some internet tools (MS Word files and html
> examples) you can download and look through.
Isn't that the perl script which had some bug(s) major enough
for more than two people to come to this ng for help last
month? If so, Tom Mornini's suggestion might be a better bet.
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: 8 Jul 1999 13:46:26 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: Webpages and Perl-Couple of Questions
Message-Id: <slrn7o9sf8.vka.abigail@alexandra.delanet.com>
Bart Lateur (bart.lateur@skynet.be) wrote on MMCXXXVII September MCMXCIII
in <URL:news:3784a3c8.22678257@news.skynet.be>:
`` Abigail wrote:
``
`` >Maybe in Belgium there are free T-shirts for everything you do,
`` >but here in the states, you have to buy everything.
``
`` Quite the contrary. The one time I've been in the States, I noticed that
`` some people sold T-shirts really cheap, 2$ or so. Crappy T-shirts: wash
`` them once, and they're torn/out of shape/whatever.
And you expect me to buy such T-shirts?
Abigail
--
perl -e '* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
/ / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / /
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %;
BEGIN {% % = ($ _ = " " => print "Just Another Perl Hacker\n")}'
-----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
http://www.newsfeeds.com The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including Dedicated Binaries Servers ==-----
------------------------------
Date: Thu, 08 Jul 1999 17:16:50 GMT
From: jimhutchison@metronet.ca (Jim Hutchison)
Subject: Re: Which is better, Perl, Cold Fusion or...
Message-Id: <3784dc91.242254293@news1.cal.metronet.ca>
IMHO, don't use Cold Fusion. We went through a couple revs both on NT
as well as Solaris, and they were memory pigs, unstable, etc etc etc.
An administrative hassle.
On Thu, 8 Jul 1999 10:35:08 -0400, Andrew Singer
<als48@pantheon.yale.edu> wrote:
>Hey, I'm a Yalie interning for Trade Show News Network (www.tsnn.com). We
>have to decide which language to program in to connect our database to the
>web and make dynamic web pages, etc. Would you recommend, Perl, Cold
>Fusion, or some other language, like Zope or PHP? We are not looking for
>the cheapest or easiest to use language; we want the most powerful and
>reliable. Thanks a lot for your help!
>
>-Andy
>
>___________________________________________
>Andrew Singer
>300 W 108 St, Apt 1A
>NY, NY 10025
>(212)864-3515
>
>
------------------------------
Date: 1 Jul 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 1 Jul 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.
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 V9 Issue 80
************************************