[12995] in Perl-Users-Digest
Perl-Users Digest, Issue: 405 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Aug 6 14:17:56 1999
Date: Fri, 6 Aug 1999 11:10:13 -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 Fri, 6 Aug 1999 Volume: 9 Number: 405
Today's topics:
Re: New to Perl - Question About RegExpr (Anno Siegel)
Re: New to Perl - Question About RegExpr <smiles@wfubmc.edu>
Newbie question about $_ steveeq1@earthlink.net
Re: Newbie question about $_ (Michel Dalle)
perl script running as a different uid cannot load pack <paul.glidden@unisys.com>
Re: Problem reading forms with perl <cassell@mail.cor.epa.gov>
Re: Problem reading forms with perl <cassell@mail.cor.epa.gov>
Re: Problem reading forms with perl <cassell@mail.cor.epa.gov>
problem with DBI.pm <phantomias@hotmail.com>
Query: Methods for uniform exception handling <rwilliamson@uno.gers.com>
Re: Quick Question :) <vmurphy@gamora.ndhm.gtegsc.com>
Re: Sorting arrays in perl (Twarren10)
storing data that is read in in an external file (Anno Siegel)
Re: storing data that is read in in an external file (Anno Siegel)
Re: Why is it.... [REPOST] (Larry Rosler)
Re: Win32 Perl 'alarm()' substitution? <tcharron@my-deja.com>
Digest Administrivia (Last modified: 1 Jul 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 6 Aug 1999 17:31:28 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: New to Perl - Question About RegExpr
Message-Id: <7of65g$git$1@lublin.zrz.tu-berlin.de>
Derek Battams <dbattams@canada.com> wrote in comp.lang.perl.misc:
>I've just started to write CGIs in Perl (I've been writing them in C) and
>I've come across the following line in a script that someone else has
>written:
>
>$Config{'required'} =~ s/(\s+|\n)?,(\s+|\n)?/,/g;
>
>I realize that this is a regular expression, but here are my questions...
>
>(1) Exactly what does the "=~" operator do? I've been reading the limited
>information that I have found on the Internet, but this has not come up.
It's explained in perldoc perlop
>(2) Are there any other similar operators like "=~"? If so, what do they
>do?
Define similar. Or read all of perlop.
>(3) Where is the best place to learn about regular expressions (how to write
>them, etc.)?
perldoc perlre
>Sorry for the silly newbie questions, but your help would be greatly
>appreciated.
We've seen sillier. But the answers are all on your hard disk, at
least if you have a reasonably recent installation of Perl.
Anno
------------------------------
Date: Fri, 06 Aug 1999 13:17:15 -0400
From: Steve Miles <smiles@wfubmc.edu>
Subject: Re: New to Perl - Question About RegExpr
Message-Id: <37AB189B.E4B3AF4B@wfubmc.edu>
Hi Derek,
> (1) Exactly what does the "=~" operator do? I've been reading the limited
> information that I have found on the Internet, but this has not come up.
In your case, an example would be:
$temp = "goose";
$temp =~ s/o/e/g;
print $temp; # $temp will now be "geese" - the o's were replaced with
e's.
The "s" at the start designates a switching or replacing of the first set of
characters ("o" in this case) with the second set ("e" in this case). They are
separated by the "/" and the "g" at the end tells the script to replace all
occurences of "0" in $temp....hope this helps a little. This is one of the most
commonly used regex's.
> (2) Are there any other similar operators like "=~"? If so, what do they
> do?
well, there's quite a few. You could look in the Perl documentation for them.
The opposite of "=~" is "!~" and there are many others...they are mainly
comparison operators. ".=" adds something to an existing string...
> (3) Where is the best place to learn about regular expressions (how to write
> them, etc.)?
Most Perl books have a list of them. In fact, there's a book called Mastering
Regular Expressions that you can find at oreilly.com that could help. But most
beginner Perl books have lists of these operators and what they do.
Good Luck,
Steve
=============================================
Steve Miles (smiles@wfubmc.edu)
Wake Forest University School of Medicine
5019 Hanes, Medical Center Blvd.
Winston-Salem, NC 27157
Phone: 336.716.0454 FAX: 336.716.7200
=============================================
------------------------------
Date: Fri, 06 Aug 1999 17:34:57 GMT
From: steveeq1@earthlink.net
Subject: Newbie question about $_
Message-Id: <7of6c0$gok$1@nnrp1.deja.com>
Ok,
here is a newbie question about $_. If $_ is at a certain point. Is
there a way to move it to the PREVIOUS line instead of the next line?
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: Fri, 06 Aug 1999 17:53:48 GMT
From: michel.dalle@usa.net (Michel Dalle)
Subject: Re: Newbie question about $_
Message-Id: <7of7ja$6jq$1@news.mch.sbs.de>
In article <7of6c0$gok$1@nnrp1.deja.com>, steveeq1@earthlink.net wrote:
>Ok,
>
>here is a newbie question about $_. If $_ is at a certain point. Is
>there a way to move it to the PREVIOUS line instead of the next line?
>
In what context ? Something like the reverse of 'next', maybe ?
while (<>) {
if (/too far/) {
# Oops, I'm too far !
# I want to go back to the previous line :
#previous; # this doesn't work !!!!
}
}
That seems to be a rather silly way to program...
Anyway, you can go back to the previous 'line' for files (seek),
databases (see DBI), etc. but the method differs depending on
the context. Of course, you could always save the previous
line somewhere too...
HTH,
Michel.
------------------------------
Date: Fri, 6 Aug 1999 11:44:11 -0500
From: "Paul Glidden" <paul.glidden@unisys.com>
Subject: perl script running as a different uid cannot load package
Message-Id: <7of3cf$pnj$1@eanews1.unisys.com>
I have a perl script that needs to run as a different uid than the user that
envokes the program. In order to do this I have turned on the suid bit.(I
am well aware of the security implications of doing this)
Unfortunately after turning on the suid bit the script can not find a
package located in the same directory under the same ownership.
I get the message:
Can't locate get_bkup.pm in @INC (@INC contains:
/usr/local/lib/perl5/PENTIUM_PR
O-svr4.0/5.00401 /usr/local/lib/perl5
/usr/local/lib/perl5/site_perl/PENTIUM_PRO
-svr4.0 /usr/local/lib/perl5/site_perl) at /dev/fd/3 line 26.
The moment I turn off the suid bit, the script loads the package without a
problem whatsoever.
What is causing this problem? How can I overcome it?
thanks,
Paul
------------------------------
Date: Fri, 06 Aug 1999 10:35:36 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Problem reading forms with perl
Message-Id: <37AB1CE8.24932ACA@mail.cor.epa.gov>
Steve Yates wrote:
>
> genelong@my-deja.com wrote:
> > What is the standard perl distribution?
>
> A "distribution" in UNIX terms is basically a software release, or what
> that software contains. The standard should be available on every
> platform that runs the software (not all UNIX machines have the same
> operating system, and not all Internet servers are UNIX). He is
> referring to the version of Perl located on your web server.
It doesn't have to be on a web server. Gene will get a lot more out
of Perl if he has a personal copy on his own PC.
> > I am trying to get onto www.cspan.org,
>
> Try www.cpan.org. :) Comprehensive Perl Archive Network.
>
> > Where do I get the FAQ?
>
> The FAQ can be found on that site.
It's a lot easier reading and searching the FAQ if you have it locally.
Plus the ActiveState Perl install comes with the win32 Perl FAQ, which
has answers to some questions Gene is likely to be looking for soon.
Like "Why the heck can't I get fork() to work?" :-)
> >perldoc -q "How do I decode a CGI form"
>
> This perldoc command searches for the question in the perl doc files.
> He is assuming you have access to a shell account on UNIX, which many
> people don't. You'll see a lot of one line posts in this group to the
> effect of "man xxxx" (display the manual for xxx). Fortuantely CPAN has
> the perl documentation also.
No no no no no. perldoc runs on everything [well, I haven't seen a
modern install of Perl where perldoc wasn't included]. This is a
*good* way to use the docs in win32, despite TomC's perl-sonal [sic]
animosity toward the program.
> Now, CGI.pm is a perl module, like a unit or library in other
> languages, which contains functions you can use. In this case, CGI.pm
> provides easy access to the results of a form, and also a way to write
> HTML code from a perl script. See this link for documentation for it:
>
> http://stein.cshl.org/WWW/software/CGI
But it's easier to get the already-made PPD of CGI.pm from
ActiveState, using the ppm program which ActiveState supplies along
with the Perl installation.
David
--
David Cassell, OAO
cassell@mail.cor.epa.gov
Senior Computing Specialist
mathematical statistician
------------------------------
Date: Fri, 06 Aug 1999 10:37:20 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Problem reading forms with perl
Message-Id: <37AB1D50.C4B4CE39@mail.cor.epa.gov>
Russ Allbery wrote:
>
> Steve Yates <srt@xnet.com> writes:
>
> >> perldoc -q "How do I decode a CGI form"
>
> > This perldoc command searches for the question in the perl doc files.
> > He is assuming you have access to a shell account on UNIX, which many
> > people don't.
>
> Does perldoc not work on Windows? If not, why not?
Steve was just mistaken. perldoc *does* work in win32.. although
there are some peculiarities with its paging when using some of the
options. For discussions on this, see the archives of win32-perl-users
listserv, if you're interested.
David
--
David Cassell, OAO
cassell@mail.cor.epa.gov
Senior Computing Specialist
mathematical statistician
------------------------------
Date: Fri, 06 Aug 1999 10:40:25 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Problem reading forms with perl
Message-Id: <37AB1E09.1F1E5118@mail.cor.epa.gov>
Abigail wrote:
>
> genelong@my-deja.com (genelong@my-deja.com) wrote on MMCLXVI September
> MCMXCIII in <URL:news:7odj31$cdp$1@nnrp1.deja.com>:
> ?? Ok, elephant, now you've got me totally lost. Please be patient.
> ??
> ?? What is the standard perl distribution? I learned perl out of a book,
> ?? and ftp'd it to my server with ws_ftp. I don't have any standard
> ?? distribution.
>
> The standard Perl distribution is the distribution released by whoever
> Larry appointed as pumpkin. Currently, that's Sarathy.
s/pumpkin/pumpking/;
Unless Sarathy *likes* being referred to as a big yellow gourd.
[snippety]
> ?? everyone else knows unix, and I don't - I run under Windows 98/IE 5.
>
> That can be fixed. And do you honestly believe a web browser is a
> fundamental part of your OS?
I believe Bill Gates has personally assured the U.S. government that
this is the case. :-)
David
--
David Cassell, OAO
cassell@mail.cor.epa.gov
Senior Computing Specialist
mathematical statistician
------------------------------
Date: Fri, 06 Aug 1999 19:32:35 +0200
From: mao <phantomias@hotmail.com>
Subject: problem with DBI.pm
Message-Id: <37AB1C33.FF7ECA0C@hotmail.com>
i've a problem with DBI.pm:
i downloaded ActivePerl 518 (as i use Win95), the latest version of
DBI.pm (113) and copied it into the perl/lib directory.
then i got the mysql.pm from mysql.org.
i also downloaded some perl scripts that use DBI.pm to contact a mysql
db.
i tried to run them, but everytime i got the errmsg "can't locate
loadable object in @NIC...".
the line with the error was:
"use DBI;"
but all scripts use this syntax.
i tried it with:
"use DBI::MySQL;"
fine, no errors (i still don't know why all the scripts (and the DBI.pm
FAQ) make it w/o "::MySQL")
anyway, then i wanted to use the DBI->connect() object/method to connect
my db, know i get the errmsg:
"object connect not found via dbi.pm..."
what's wrong with my source? or is there something wrong with my DBI.pm?
PLEASE EMAIL ME!
thanks a lot,
malte
------------------------------
Date: Fri, 6 Aug 1999 10:37:44 -0700
From: "Rusty Williamson" <rwilliamson@uno.gers.com>
Subject: Query: Methods for uniform exception handling
Message-Id: <S3Fq3.292$jd2.19930@news.connectnet.com>
Hi!
I'm seeking suggestions on PERL5 exception handling. I need a common method
and format for reporting run-time exceptions from multiple scripts. My
query does not relate to detection methods ($!, $?, $@ or using eval) but
rather processing and reporting errors after their detection.
General requirements and issues include:
- Handling for all run-time errors: PERL, UNIX, invalid data, etc.
- Writing all messages from multiple PERL scripts to a common log either
directly or via an intermediate process (I've learned that I can't depend on
UNIX file locking and be portable).
- Portability.
- A common message format
- Adherence to any existing industry standards and conventions. I know of
none (do you?) and will check the WC3 site (where else?).
- The ability to report and carry on, or to perform a controlled exit (file
cleanup, reply to a client when doing CGI, etc.)
- Processes include CGI scripts, background scripts ran by CGI scripts,
batch scripts run by cron and interactive command line scripts.
- The utility also includes C++ programs and shell scripts. All should use
the same message format and error log (or intermediate process).
- Ease of use.
I'm reviewing exception modules on CPAN though there's not much (know any
other sources?). I'd rather use an existing time-worn and tested module but
can write my own without too much trouble if I absolutely must.
Any suggestions you think of while reading this will be appreciated.
- Is there something commonly used?
- Does anyone have anything that they are using?
- Is this something commonly written for each application?
- Any feedback on any of the issues?
Thanks in advance for your time and any help you can offer!
Rusty Williamson
------------------------------
Date: Fri, 06 Aug 1999 16:37:25 GMT
From: Vincent Murphy <vmurphy@gamora.ndhm.gtegsc.com>
Subject: Re: Quick Question :)
Message-Id: <xjglnbo9871.fsf@gamora.ndhm.gtegsc.com>
>>>>> "Ivan" == Ivan Berg <iberg@montana.edu> writes:
Ivan> Anybody know how to add two binary number together.
Ivan> When adding using th '+' operator I get a scientific notation number.
Ivan> For instance, how would one add '011' and 100' and get '111'??
perl -e 'sub b2d{return unpack(qq(N),pack(qq(B32),substr(qq(0)x32 . shift, -32)))};sub d2b{ $str=unpack(qq(B32), pack(qq(N), shift));$str =~ s/^0+(?=\d)//;return $str}; print d2b( b2d('011') + b2d('100') ),qq(\n);'
--
Vinny
------------------------------
Date: 06 Aug 1999 16:23:59 GMT
From: twarren10@aol.com (Twarren10)
Subject: Re: Sorting arrays in perl
Message-Id: <19990806122359.02193.00007547@ng-ft1.aol.com>
examine this, then try it.
foreach $stuff (sort { $totsecs{$b}->[0] <=> $totsecs{$a}->[0] } keys %totsecs)
{
..etc
------------------------------
Date: 6 Aug 1999 17:07:32 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: storing data that is read in in an external file
Message-Id: <7of4ok$gfs$1@lublin.zrz.tu-berlin.de>
<chrisman81@my-deja.com> wrote in comp.lang.perl.misc:
>I want to open a file, read in all records from the file, and match
>cases, printing true returns to an external file. Also, I have many
>records, each with many fields. How can I make it so that new records
>are only recognized when there is a return character, or is that already
>default?
I'm not sure what you mean. If you read from a file like you do
below, then every line you get in $_ will indeed have a "\n" at
the end (except possibly for the last one). If by "return character"
you mean "\r", you will have to match that explicitly. Also look up
what $/ does.
>
>#!/usr/local/bin/perl -w
>open(FILE "/path/file");
>while(<FILE>) {
> if(/match_this_expression/) {
> what do i need here to print matched cases to an external
^^^^^
> file?;
> }
>}
>
Look up the documentation:
perldoc -f print
Anno
------------------------------
Date: 6 Aug 1999 17:00:56 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: storing data that is read in in an external file
Message-Id: <7of4c8$geg$1@lublin.zrz.tu-berlin.de>
<chrisman81@my-deja.com> wrote in comp.lang.perl.misc:
>I want to open a file, read in all records from the file, and match
>cases, printing true returns to an external file. Also, I have many
>records, each with many fields. How can I make it so that new records
>are only recognized when there is a return character, or is that already
>default?
>
>
>#!/usr/local/bin/perl -w
>open(FILE "/path/file");
>while(<FILE>) {
> if(/match_this_expression/) {
> what do i need here to print matched cases to an external
^^^^^
> file?;
> }
>}
>
Look up the documentation:
perldoc -f print
Anno
------------------------------
Date: Fri, 6 Aug 1999 11:00:07 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Why is it.... [REPOST]
Message-Id: <MPG.1214c27c7498ac4e989ded@nntp.hpl.hp.com>
In article <7oekm6$fv0$1@lublin.zrz.tu-berlin.de> on 6 Aug 1999 12:33:10
-0000, Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> says...
...
> At another point in this thread, Abigail said (and I hope I don't misquote
> too rudely) "If you you lack talent you'll have to make do with hard
> work". Well, I don't think there is that much make-do. The popular
> Edison quote about genius being 1% inspiration and 99% perspiration is
> often misunderstood. He doesn't say that only one percent of what a
> genius does is really genial, but genius *is* ninety-nine percent work.
> What he doesn't say is what makes the genial, or less pretentiously,
> talented, person work so hard.
gen'ial adj. 1. Having a pleasant or friendly disposition or manner;
cordial and kindly. See Synonyms at "gracious". 2. Conducive to life,
growth, or comfort; mild: "the genial sunshine . . . saturating his
miserable body with its warmth" (Jack London). 3. Obsolete. Relating to
or marked by genius. 4. Obsolete. Of or relating to marriage; nuptial.
[Latin geni³lis, festive, from genius, spirit of festivity. See gen-
below.] --ge'ni·al'i·ty or gen'ial·ness n. --gen'ial·ly adv.
Clearly you have the obsolete definition 3 in mind. It is not at all
compatible with definitions 1 or 2, and is in fact rather amusing.
I don't think that English now has an adjective form of 'genius', other
than the compound geniuslike, which is ugly.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Fri, 06 Aug 1999 17:50:19 GMT
From: Thomas Charron <tcharron@my-deja.com>
Subject: Re: Win32 Perl 'alarm()' substitution?
Message-Id: <7of78m$hij$1@nnrp1.deja.com>
I just came accross this searching for exactly what you're asking
about.. In my case, I have a Perl/Tk program that I need to have poll
something ever once and a while, and I can't for the life of me figure
out what I'm going to need to do.. Every several seconds I need to be
able to call 'Process(1)' on my object, and well, I can't.. :-{
In article <7nshj9$grs@news.dns.microsoft.com>,
"Doug Carter" <namekuji@hotmail.com> wrote:
> I've been beating my head against the wall trying to figure out a
> substitution for the alarm() function. I know it can be done since the
> LWP::UserAgent module supports a timeout. I can't find in the code
where
> it's implemented. I really need to be able to timeout functions in
case they
> hang. Sleep() won't work since that hangs the process for x amount of
time.
> If not for the lack of a fork() function, I would start another
thread and
> have it act as the timer. Has anyone got any clues? I've tried using
the
> POSIX module, but that didn't work. Do I have to make direct C
function
> calls? Or some direct call to the Win32API?
>
> Desperate,
> DJ
>
>
--
--
Thomas Charron
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
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 405
*************************************