[11717] in Perl-Users-Digest
Perl-Users Digest, Issue: 5317 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Apr 7 05:27:54 1999
Date: Wed, 7 Apr 99 02:00:19 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Wed, 7 Apr 1999 Volume: 8 Number: 5317
Today's topics:
another perlshop question... <sales@videogameplay.com.au>
Re: Can i do tcp/ip programming on NT platforms? <aspinelli@ismes.it>
Re: can't open file from script <ronald_f@my-dejanews.com>
Re: can't open file from script <kamran@norsar.no>
Re: flocking question - worried <c-denman@dircon.co.uk>
Re: flocking question - worried <c-denman@dircon.co.uk>
Re: flocking question - worried (Sam Holden)
Re: flocking question - worried (Sam Holden)
Re: Help with Sorting Routine <kelly@pcocd2.intel.com>
Re: Is Perl the right tool for the job (Robert Horvick)
Re: leap year? <ddelikat@protix.com>
Re: Most elegant random string generator? (and => oddit (Larry Rosler)
Re: Most elegant random string generator? (and => oddit (Tramm Hudson)
Re: Most elegant random string generator? (and => oddit (Sam Holden)
Re: Newbie to PERL - SUGGESTION NEEDED index file (Tad McClellan)
Re: Perl as a first programming language - suitability, (Ran)
Perl IDE/GUI for Linux <sauro@fol.it>
Re: random number ( -w ) <indexfinger@usa.net>
Re: random number ( -w ) (Sam Holden)
Re: random number (Larry Rosler)
Re: regexp matching digits (Tad McClellan)
RFC: new module File::FlockDir (long) (William Herrera)
Re: Signals Question (Charles DeRykus)
This installation make me nut, please help! <ypang@graphnet.com>
User authentication <sertim@imaginet.fr>
using "require example.cgi" on NT <indexfinger@usa.net>
Re: using "require example.cgi" on NT (Sam Holden)
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 7 Apr 1999 18:09:06 +1000
From: "Video Gameplay Sales" <sales@videogameplay.com.au>
Subject: another perlshop question...
Message-Id: <370b12e6.0@news.internex.net.au>
Great script, one tiny problem..
Is there a way to make it work, without having to go through the "Enter
Store" crap for it to initialize?
Too bad if someone arrives at a purchase page without coming through the
front entry page.....
Any help would be greatly appreciated...
PJ
------------------------------
Date: Wed, 07 Apr 1999 09:59:12 +0200
From: Andrea Spinelli <aspinelli@ismes.it>
Subject: Re: Can i do tcp/ip programming on NT platforms?
Message-Id: <370B1050.35AAD268@ismes.it>
Zenin wrote:
>
> smnayeem@my-dejanews.com wrote:
> : most of the socket functions of perl comes direct from unix, but how will
> : i do these on NT platform? if anyone knows please let me know, id greatly
> : appreciate ur help.
>
> I've used IO::Socket with no differences for client code.
> I wouldn't try to write really fancy code (eg, a server), but most
> standard client code should be fine.
I *did* use Perl sockets on NT for writing a server, and it's
working fine!
Also, consider that if you are going to write a HTTP server,
the class HTTP::Daemon provides all you need. And
it comes with the standard Perl distribution!
HTH
Andrea
------------------------------
Date: Wed, 07 Apr 1999 06:23:04 GMT
From: Ronny <ronald_f@my-dejanews.com>
To: kamrani@ifi.uio.no
Subject: Re: can't open file from script
Message-Id: <7eetk3$dep$1@nnrp1.dejanews.com>
(this message posted AND mailed)
In article <370A0E54.4E27@ifi.uio.no>,
Kamran <kamrani@ifi.uio.no> wrote:
> I need to open a file for writing on a disk mounted on my workstation
> from inside a perl script. While I can write a file on the disk
> manually,
> I fail to do that from the script. I have checked the user id and it
> is ok. Do I have to set additional property bit on the script ?
No. What kind of error did you get? Post the script (or mail it to me) and
what $! says after the open failure.
Ronald
--
Ronald Fischer <ronald_f@my-dejanews.com>
http://ourworld.compuserve.com/homepages/ronald_fischer/
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Wed, 07 Apr 1999 10:03:07 +0200
From: Kamran Iranpour <kamran@norsar.no>
To: Kamran <kamrani@ifi.uio.no>
Subject: Re: can't open file from script
Message-Id: <370B113B.7218@norsar.no>
Kamran wrote:
>
> Hi
>
> sorry if this sounds elementary or misappropriate.
> I need to open a file for writing on a disk mounted on my workstation
> from inside a perl script. While I can write a file on the disk
> manually,
> I fail to do that from the script. I have checked the user id and it
> is ok. Do I have to set additional property bit on the script ?
>
> Thanks in advance
>
> Kamran
Thanks for the help folks. It seems that I did some elementary
blunder. There was already another file with the same name but
different owner which I failed to discover. Using "ls -ltr"
to check the last file modified, I didn't see the file with
the same name.
Thanks again
Kamran
------------------------------
Date: Wed, 7 Apr 1999 08:47:54 +0100
From: "Chris Denman" <c-denman@dircon.co.uk>
Subject: Re: flocking question - worried
Message-Id: <370b0d7f@glitch.nildram.co.uk>
Before you get on your high horse, the code in question is NOT a page hit
counter. The counter keeps track of records in a database and is
incremented as records are added.
Plus, the code never crashes, the server does (due to others sharing it).
I just asked a question, and expected a normal answer, not a wasteful
presumptuous comment.
ChrisD
Jonathan Feinberg wrote in message ...
>"Chris Denman" <c-denman@dircon.co.uk> writes:
>
>> The flocking side of things is not a problem, I am just worried what
>> happens when a file is locked and the server crashes before the file
>> is unlocked.
>
>If your web server crashes often enough that this is an issue, you
>have *much* bigger problems than your hit counter.
>
>--
>Jonathan Feinberg jdf@pobox.com Sunny Brooklyn, NY
>http://pobox.com/~jdf
------------------------------
Date: Wed, 7 Apr 1999 08:58:38 +0100
From: "Chris Denman" <c-denman@dircon.co.uk>
Subject: Re: flocking question - worried
Message-Id: <370b1003@glitch.nildram.co.uk>
Why has everyone jumped to the conclusion that I have written a page
counter? Do you all think that people that ask for advice on this newsgroup
are not capable of writing code of any complexity?
I am relatively new to perl, but not new to programming - I have coded on
z80 based processors up to programming the Sony Playstation.
I asked a simple question where what the counter was for was not really
relevant. I only asked whether a file that is locked stays locked after a
crash.
That as may be not a be a perl specific question, but many good perl
programmers must have come across this sort of problem in the past (and
yes, it is also platform dependent).
Thanks for the constructive criticism where found, it's appreciated.
ChrisD
Chris Denman wrote in message <3709cc2e.0@glitch.nildram.co.uk>...
>Hi group,
>
>Something is playing on my mind, and I hope someone out there can put my
>mind at rest.
>
>I have a simple counter file, which increases by one, and can be increased
>by anyone at any time.
>
>The flocking side of things is not a problem, I am just worried what
happens
>when a file is locked and the server crashes before the file is unlocked.
>
>Will this file be forever locked, making that file not accessible -
>effectively 'crashing' the whole file incrementing proceedure?
>
>Comments would be greatly appreciated.
>
>ChrisD
>
>
------------------------------
Date: 7 Apr 1999 08:37:28 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: flocking question - worried
Message-Id: <slrn7gm6a8.pbb.sholden@pgrad.cs.usyd.edu.au>
On Wed, 7 Apr 1999 08:47:54 +0100, Chris Denman <c-denman@dircon.co.uk> wrote:
>Before you get on your high horse, the code in question is NOT a page hit
>counter. The counter keeps track of records in a database and is
>incremented as records are added.
Wouldn't it make more sense for the database to keep track of how many
records it has - since it needs to know anyway...
>
>Plus, the code never crashes, the server does (due to others sharing it).
The as stated you have bigger problems. Getting a server that doesn't
crash would be a good investment...
--
Sam
In case you hadn't noticed, Perl is not big on originality.
--Larry Wall
------------------------------
Date: 7 Apr 1999 08:40:47 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: flocking question - worried
Message-Id: <slrn7gm6gf.pbb.sholden@pgrad.cs.usyd.edu.au>
On Wed, 7 Apr 1999 08:58:38 +0100, Chris Denman <c-denman@dircon.co.uk> wrote:
>Why has everyone jumped to the conclusion that I have written a page
>counter? Do you all think that people that ask for advice on this newsgroup
>are not capable of writing code of any complexity?
Because that is what 99.99% of all questions regarding a counter using a file
on clpm are about. No.
--
Sam
If your language is flexible and forgiving enough, you can prototype
your belief system without too many core dumps.
--Larry Wall
------------------------------
Date: 06 Apr 1999 21:26:48 -0700
From: Michael Kelly - FVC PCD VET ~ <kelly@pcocd2.intel.com>
Subject: Re: Help with Sorting Routine
Message-Id: <us2n20lm4xj.fsf@fht002.fm.intel.com>
Crowe,
I use hashes of hashes to sort. Try making the number the first key
pointing to a list of user names. Like this:
untested
push ($sorted{$score}, $name);
to get it out:
foreach $sss (sort keys %sorted) {
foreach $nnn (sort @{sorted{$sss}}){
Print "$nnn:$sss;
} # END of foreach $nnn;
} # END of foreach $sss;
After the push, you can add the text and moretext as a list like this:
again untested
$sorted{$score}{$name}[1] = $somebig string;
$sorted{$score}{$name}[2] = $someotherbig string;
or for a hash of a hash of a hash
$sorted{$score}{$name}{$sometext} = $somemoretext;
Programming Advanced Perl is better for these kind of arrays.
"The Crowe" <crowe@darkspiral.com> writes:
>
> I need some help with a sorting routine. I've read the sections in
> Learning Perl, Programming Perl and the Perl Cookbook and I still
> can't figure out how to get this to work.
>
> Below is my script, it works as is. Its reading from a db file that looks
> like this.
>
> crowe:2
> userx:42
> blah:19
> etc:21
>
> What I want is a DB file that looks like this
>
> crowe:2:texthere:moretexthere
> userx:42:something:somethingelse
> blah:19:moreinfo:evenmoreinfo
> etc:21:almost:done
>
> The below sorts on Numerical order by the second field in the db file
> and then prints the NAME , then Number.
>
> However, I'd like to be able to use EACH field as a variable and print
> it with corresponding info.. like $field1 $filed2 $field3 $field4.
>
> All the examples in the books are for sorting files with 2 fields...
>
> Can someone help me figure out how to do it with multiples???
>
> Thanx in advance, below is the current code!
>
> Crowe
>
--
Not speaking for Intel
Michael Kelly (the one in Folsom)
------------------------------
Date: 7 Apr 1999 05:03:50 GMT
From: rphorvic@gloria.cord.edu (Robert Horvick)
Subject: Re: Is Perl the right tool for the job
Message-Id: <7eeovm$bnp$3@sonic.cord.edu>
As a thought - You might consider a solution where perl generates xml (or
sgml) documents of a general form. Then have a style sheet for each
differant type of report you might want to generate -each of these will be
processed and produce your desired html. It is a very flexible solution
and allows you to have multiple style sheets for the same marked data.
Because God knows that the report they want tomorrow will probably be
generated from the data you have today ... so write a new style sheet.
Its a lot easier ... in my opinion :)
Best of luck,
Robert
William Sanns (wsanns@pog.ufl.edu) wrote:
: I've just come from a "microsoft" shop and am now managing a web based
: remote data entry system. We have a Java front end and Oracle (V7.3.4)
: on the back end. We are currently running on AIX but will migrate to
: Linux within the next 3 months. Java is working fine for most of the
: client work, but there are many instances where I would just like to
: present the user with a "report" from the database in html format (I
: would have used ASP in my "previous life"). From what I've seen, Perl
: looks like its easy to pick up, but is it capable of creating a "dynamic
: length" html page (the page would have anywhere from 0 to n number of
: records returned to the user based on their selections). We are
: considering PHP, but Perl seems more widely supported.
: Thanks in advance
: Bill
--
+-----------------------+----------------------------------------+
| Robert P. Horvick | http://www.cord.edu/homepages/rphorvic |
| Great Plains Software | If you think I speak for my employer |
| rhorvick@acm.org | I've a tower in Paris to sell you |
+-----------------------+----------------------------------------+
Did you know that the voice tapes easily identify the Russian pilot
that shot down the Korean jet? At one point he definitely states:
"Natasha! First we shoot jet, then we go after moose and
squirrel."
-- ihuxw!tommyo
------------------------------
Date: Tue, 06 Apr 1999 16:41:20 -0500
From: David Delikat <ddelikat@protix.com>
Subject: Re: leap year?
Message-Id: <370A7F80.2F1C@protix.com>
Abigail wrote:
>
> sub _'_{$_'_=~s/$a/$_/}map{$$_=$Z++}Y,a..z,A..X;*{($_::_=sprintf+q=%X==>"$A$Y".
> "$b$r$T$u")=~s~0~O~g;map+_::_,U=>T=>L=>$Z;$_::_}=*_;sub _{print+/.*::(.*)/s}
> *_'_=*{chr($b*$e)};*__=*{chr(1<<$e)};
> _::_(r(e(k(c(a(H(__(l(r(e(P(__(r(e(h(t(o(n(a(__(t(us(J())))))))))))))))))))))))
this boggles the mind.
-dav
--
<((((><
Consultant: Internet, Database, Business Systems
Unix/Linux, Windows95/NT
mailto:david-delikat@usa.net / http://obj.webjump.com/
------------------------------
Date: Tue, 6 Apr 1999 22:04:59 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Most elegant random string generator? (and => oddity)
Message-Id: <MPG.1174874d32295723989858@nntp.hpl.hp.com>
[Posted and a courtesy copy sent.]
In article <7eel3t$lbq@llama.swcp.com> on 6 Apr 1999 21:57:49 -0600,
Tramm Hudson <hudson@swcp.com >says...
...
> Weird -- perl 5.004_01 does this on my x86 Linux box:
>
> : straylight:/tmp% perl -e 'x-a => b'
> : syntax error at -e line 1, near "x-a"
> : Execution of -e aborted due to compilation errors.
> : zsh: segmentation fault (core dumped) perl -e x-a => b
x-a is the subtrction of the bareword a from the bareword x, so a syntax
error. But the core dump is unreasonable.
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 6 Apr 1999 23:59:45 -0600
From: hudson@swcp.com (Tramm Hudson)
Subject: Re: Most elegant random string generator? (and => oddity)
Message-Id: <7ees8h$mok@llama.swcp.com>
[cc'd to one of the Larries]
In article <MPG.1174874d32295723989858@nntp.hpl.hp.com>,
Larry Rosler <lr@hpl.hp.com> wrote:
>Tramm Hudson <hudson@swcp.com >says...
>...
>> Weird -- perl 5.004_01 does this on my x86 Linux box:
>>
>> : straylight:/tmp% perl -e 'x-a => b'
>> : syntax error at -e line 1, near "x-a"
>> : Execution of -e aborted due to compilation errors.
>> : zsh: segmentation fault (core dumped) perl -e x-a => b
>
>x-a is the subtrction of the bareword a from the bareword x, so a syntax
>error. But the core dump is unreasonable.
If that is the case, then why is foo-bar ok:
: % perl -e 'foo-bar => "baz"'
: % perl -e 'foo-z => "bar"'
: syntax error at -e line 1, near "foo-z"
: Execution of -e aborted due to compilation errors.
: zsh: segmentation fault (core dumped) perl -e foo-z => "bar"
SHouldn't both of these cause errors? Yes, the core dump is a
bit much (it appears to be in _IO_fclose, called by Perl_my_failure_exit,
but I do not have a debugging version). Anyway, 5.004_04 appears
to have fixed that part of it.
In the silly example, I showed how x-x could be interpreted as
the repeat operator followed by the result of the -x test:
: % perl -e 'print "foo\n" x-x "/"'
: foo
: % perl -e 'print "foo\n" x-q "/"'
: Unrecognized file test: -q at -e line 1.
Which implies to me that the parser is scanning for something
approximating /-(\w)(?=\W)/ and treats $1 as the test operator.
In the => case, it seems that the syntax error is a missing
argument to the file test. It is not a parsing bug, just
a somewhat confusing interaction of many different rules.
Good thing I'm not trying to write a pretty printer...
No big deal.
Tramm
--
o hudson@swcp.com tbhudso@cs.sandia.gov O___|
/|\ http://www.swcp.com/~hudson/ H 505.266.59.96 /\ \_
<< KC5RNF @ N5YYF.NM.AMPR.ORG W 505.284.24.32 \ \/\_\
0 U \_ |
------------------------------
Date: 7 Apr 1999 06:53:23 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: Most elegant random string generator? (and => oddity)
Message-Id: <slrn7gm073.mrp.sholden@pgrad.cs.usyd.edu.au>
On 6 Apr 1999 23:59:45 -0600, Tramm Hudson <hudson@swcp.com> wrote:
>[cc'd to one of the Larries]
>
>In article <MPG.1174874d32295723989858@nntp.hpl.hp.com>,
>Larry Rosler <lr@hpl.hp.com> wrote:
>>Tramm Hudson <hudson@swcp.com >says...
>>...
>>> Weird -- perl 5.004_01 does this on my x86 Linux box:
>>>
>>> : straylight:/tmp% perl -e 'x-a => b'
>>> : syntax error at -e line 1, near "x-a"
>>> : Execution of -e aborted due to compilation errors.
>>> : zsh: segmentation fault (core dumped) perl -e x-a => b
>>
>>x-a is the subtrction of the bareword a from the bareword x, so a syntax
>>error. But the core dump is unreasonable.
The real answer (I think anyway) was given in the post I'm replying to (that
x is an operator not a bare word, and -<a lot of single chars> is a file test).
I'd just thought I'd add by saying that subtracting two bare words is perfectly
valid since the docs state that bareword is treated as a quoted string.
So the strings get converted into numbers (0) and subtracted...
--
Sam
comments on data are usually much more helpful than on algorithms
--Rob Pike
------------------------------
Date: Tue, 6 Apr 1999 20:33:18 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Newbie to PERL - SUGGESTION NEEDED index file
Message-Id: <e49ee7.l52.ln@magna.metronet.com>
Janie Chu (jychu@us.oracle.com) wrote:
: I'm new to PERL. I'm working on a web site which gives user the ability
: to do query against a file which is created in EXCEL and saved as COMMAS
: SEPARATED VALUE file (.csv). The file contains data such as product
: name and product version. There is a one to many relationship between
: product name and product version. In other words, one product can have
: more than one version. What is the best way to handle this so, that my
: list of value will not contain duplicate values. Any help you can offer
: is greatly appreciated.
So you want the products unique across the whole set of products,
and the versions unique within each product?
If you hear any of these words in the problem description:
unique
duplicate
in
cross-reference
lookup
your brain (once Perlification is complete) should shout HASH!
For your problem above, a hash of (references to) hashes
seems like it would do the trick.
See 'perlref.pod' (References) and 'perldsc.pod' (Data Structures
Cookbook) in the standard Perl docs.
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: 7 Apr 1999 08:35:50 GMT
From: ran@netgate.net (Ran)
Subject: Re: Perl as a first programming language - suitability, good books ?
Message-Id: <7ef5d6$k8t$1@remarQ.com>
In <7edtvp$v10$1@news4.svr.pol.co.uk>, "Jonathan" <jonathan@meanwhile.freeserve.co.uk> writes:
>A friend of mine from an arts background is interested in learning to
>program, partly from intellectual curiousity and partly for career reasons.
>She's extremely smart and a great problem solver, but she's never written a
>program in any language. Until recently I didn't know what language to
>suggest to her - Basic's too ugly
Despite its suckiness as a tool for large-scale projects, Basic remains
a pretty good way for beginners (that is, after all, what the "B"
stands for ;-) to write very simple programs.
One big plus it has from the rank beginner's point of view is the
ability to type in a single line of code and have the interpreter run it
and generate results. This "sandbox" feature can be a huge help when
trying to develop the "programmer's perspective" (like the notion that
"a = a + 1" is *not* an "equation") that those of us who've been at it
for many years take for granted.
Perl as a first language, otoh, is a little like climbing into the
driver's seat of an 18-wheeler without ever even having ridden a
bicycle.
My suggestion: learn a small subset of Basic first. INPUT, PRINT,
IF-THEN-ELSE, FOR, and WHILE. Plus some of the arithmetic and
logical operators, and maybe a few built-in functions like SQRT. Write
a dozen or two programs, increasing in complexity to, say, about 50
lines of code. Not necessarily anything of real practical use: maybe
something along the lines of "programmable calculator tricks", like
mortgage payment schedules with the principal and interest portions for
each month.
That will give her the rudiments of understanding the need for thinking
through a design before starting to code, of expressing yourself very
literally for the benefit of mindless compilers, etc.
Plus, she'll have a greater appreciation for the power of Perl once she
actually starts to learn it ;-)
Ran
------------------------------
Date: Wed, 7 Apr 1999 07:55:56 +0200
From: "Sauro Sgatti" <sauro@fol.it>
Subject: Perl IDE/GUI for Linux
Message-Id: <7eervo$sbe$1@fe1.cs.interbusiness.it>
Hi,
Where I find Perl IDE or GUI on Linux ?
Please also reply an email.
Thnks in advance.
------------------------------
Date: Wed, 07 Apr 1999 06:52:10 GMT
From: "IndexFinger.com" <indexfinger@usa.net>
Subject: Re: random number ( -w )
Message-Id: <ugDO2.273$xI5.10326@typhoon.nycap.rr.com>
> #!usr/bin/perl -w
What does the "-w" do?
--
==================================================
SuggestSite - http://www.suggestsite.com
Word of mouth is the most powerful marketing tool.
------------------------------
Date: 7 Apr 1999 06:55:53 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: random number ( -w )
Message-Id: <slrn7gm0bp.mrp.sholden@pgrad.cs.usyd.edu.au>
On Wed, 07 Apr 1999 06:52:10 GMT, IndexFinger.com <indexfinger@usa.net> wrote:
>> #!usr/bin/perl -w
>
>
>What does the "-w" do?
perldoc perl
perldoc perlrun
You'd think people would at least read the 'perl' manpage/perldoc if not the
rest...
--
Sam
I explicitly give people the freedom not to use Perl, just as God gives
people the freedom to go to the devil if they so choose.
--Larry Wall
------------------------------
Date: Tue, 6 Apr 1999 22:16:11 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: random number
Message-Id: <MPG.117489f581636aec989859@nntp.hpl.hp.com>
[Posted and a courtesy copy sent.]
In article <7eendd$8uh$1@nnrp1.dejanews.com> on Wed, 07 Apr 1999
04:37:02 GMT, northernnj@my-dejanews.com <northernnj@my-dejanews.com
>says...
> Why doesn't the random number generator work?
It does, if you call it. Not if you print its name.
> When I put in:
>
> #!usr/bin/perl -w
> srand;
> @array = (1 .. 10);
> $random_number = "rand(@array)";
> print = "$random_number\n";
>
>
> I get:
> rand 1 2 3 4 5 6 7 8 9 10
I get a syntax error, on 'print ='. But when I correct that, I get:
rand(1 2 3 4 5 6 7 8 9 10)
Because that is the *string* you assigned to $random_number (with the
elements of @array expanded in the double-quoted context).
Try it again, without the double-quotes. And next time you post, please
cut-and-paste the real stuff, rather than mistyping it in.
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Tue, 6 Apr 1999 18:47:44 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: regexp matching digits
Message-Id: <gu2ee7.422.ln@magna.metronet.com>
frf (frf@energyinteractive.com) wrote:
: I am hoping someone can give me an elegant way to extract the
: digits from a string. (sfour030299data.log)
: Given $filename = sfour030299data.log
: I'd like to get $filedate = 030299.
my $filedate = $1 if $filename =~ /(\d+)/;
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Wed, 07 Apr 1999 07:07:45 GMT
From: posting.account@lynxview.com (William Herrera)
Subject: RFC: new module File::FlockDir (long)
Message-Id: <370b03e8.25549644@news.rmi.net>
Some of us have to run perl on Windows95. The module below actually
allows flock() to work on Windows95/98, and also allows flock() to
lock files over a network las Unix lockf() does.
Basically, I used the Perl Cookbook netlock package code as a basis
for overriding flock(). As a side effect, I also had to override
perl's open() and close(), though the functions that override these
are really just wrappers that squirrel the filename away for later
use.
I plan to put a version on CPAN later. In the meantime, I hope that
Tom and Nathan don't hate too much the use to which their book is put
here.
#####################################
#!/usr/bin/perl
####################################################
#
# file FlockDir.pm
# package File::FlockDir
# flock module for Windows9x and other systems lacking
# a good perl flock() function (not platform specific)
#
# By William Herrera, first written April 1999
#
# Usage:
# use File::FlockDir qw(open close flock);
# OR (careful)
# use File::FlockDir qw (GLOBAL_open GLOBAL_close GLOBAL_flock);
#
# Rationale: flock on Win95/98 is badly broken but
# perl code needs to be portable. One way to do
# this is to override perl's open(), flock(), and close().
# We then get an absolute file specification for all opened
# files and and use it in a hash to create a unique lock for
# the file using the File::LockDir module from __Perl Cookbook__,
# by Christiansen and Torkington (O'Reilly, 1998).
#
# The module is thus an extension of that module's nflock().
# New code is deliberately kept at a minimum. As with nflock(),
# this will allow flock() to work over a network (usually).
#
#
# Known caveats (related to those of File::LockDir):
#
# May be slow compared to unix flock().
#
# Abnormal termination may leave File::LockDir entries on drive.
# This means the directory locks set by File::LockDir must be
# removed after a system crash to prevent the module from seeing
# files locked at the time of the crash as still locked later.
#
###################################################
package File::FlockDir;
use strict;
use Exporter;
use vars qw(@ISA @EXPORT);
@ISA = qw(Exporter);
@EXPORT = qw(open close flock);
# see perlsub under "Overriding Builtin Functions" regarding
# the use (when needed to implement flock used by a _different
# package than the importing package) of the syntax
# use File::FlockDir qw(GLOBAL_open GLOBAL_close GLOBAL_flock)
sub import {
my $pkg = shift;
return unless @_;
my $sym = shift;
my $where = ($sym =~ s/^GLOBAL_// ? 'CORE::GLOBAL' : caller(0));
$pkg->export($where, $sym, @_);
}
use vars qw($Max_SH_Processes $Check_Interval %handles_to_names
%handles_to_SH_netlocks %locked_SH %locked_EX);
$Max_SH_Processes ||= 20; # predefined or 20 LOCK_SH processes per
file
$Check_Interval ||= 2; # predefined or 2 sec. between checks while
blocked
# The File::LockDir module required below is available at
# ftp.oreilly.com/examples/perl/cookbook
use File::LockDir qw(nflock nunflock);
use Carp;
# the module archive File-PathConvert-xxx is on CPAN
use File::PathConvert qw(&rel2abs);
# override open to save pathname for the handle
sub open (*;$) {
my($fh) = shift;
my($spec) = shift;
my($retval) = CORE::open(*$fh, $spec); # delegate real open.
if($retval) {
$spec =~ /\A[\s+<>]*(.+)/;
if($1) {
$handles_to_names{$fh} = rel2abs($1)
unless($handles_to_names{$fh});
}
else { carp("syntax error in File::FlockDir open for
$spec\n"); }
}
return $retval;
}
# override perl close
sub close (*) {
my($fh) = ( shift || select(select) ); # kludge for close;
$locked_SH{$fh} = 1;
__unlock($fh, 1 | 2); # release both SH and EX locks
delete $handles_to_names{$fh};
return CORE::close(*$fh); # delegate rest of close to regular close
}
# override perl flock
sub flock (*;$) {
my($fh) = shift;
my($lock) = shift;
my($s, $t, $i);
my($retval) = 0;
return __unlock($fh, $lock) if ($lock & 8);
if($lock & 1) {
$s = $handles_to_names{$fh}; # fetch file name
if($s) {
while (!nflock($s . 'EX', 1)) {
return if($lock & 4); # non-blocking
sleep $Check_Interval - 1;
}
if($locked_SH{$fh}) {
$locked_SH{$fh}++;
$retval |= 1; # success
}
else {
for($i = 0; $i < $Max_SH_Processes; ++$i) {
$t = $s . 'SH' . $i;
if(nflock($t, 0)) {
$handles_to_SH_netlocks{$fh} = $t;
$locked_SH{$fh} = $s;
$retval |= 1; # success
last;
}
}
}
nunflock($s . 'EX'); # release LOCK_EX
}
}
if($lock & 2) {
$s = $handles_to_names{$fh};
if($s) {
while (!nflock($s . 'EX', 1)) {
return if($lock & 4); # non-blocking
sleep $Check_Interval - 1;
}
for($i = 0; $i < $Max_SH_Processes; ++$i) {
$t = $s . 'SH' . $i;
while(!nflock($t, 1)) { # failed?
if ($lock & 4) { # non-blocking
while(--$i >= 0) { nunflock($s . 'SH'. $i); }
nunflock($s . 'EX');
return;
}
sleep $Check_Interval - 1; # wait for share
}
}
$locked_EX{$fh} = $s; # keep exclusive lock name
while($i >= 0) { nunflock($s . 'SH' . $i--); }
$retval |= 2; # success
}
}
return $retval; # 1 for LOCK_SH, 2 for LOCK_EX, 3 for both set.
}
# "private" helper function __unlock
sub __unlock {
my($fh) = shift;
my($lock) = shift;
my($s, $t);
if ( ($lock & 1) && $locked_SH{$fh} ) {
--$locked_SH{$fh};
if ($locked_SH{$fh} <= 0) {
$s = $handles_to_SH_netlocks{$fh};
if($s) {
nunflock($s);
delete $handles_to_SH_netlocks{$fh};
}
delete $locked_SH{$fh};
}
}
if ( ($lock & 2) && $locked_EX{$fh} ) {
$s = $handles_to_names{$fh};
if($s) {
nunflock($s . 'EX');
}
delete $locked_EX{$fh};
}
return $lock;
}
# default cleanup to avoid leftover temp directories
END {
my ($fh);
foreach $fh (keys %locked_EX) {
__unlock($fh, 2);
}
foreach $fh (keys %locked_SH) {
$locked_SH{$fh} = 1;
__unlock($fh, 1);
}
}
# end of package
1;
# pod docs will have to go here if we get that far
#########################################
---
The above from: address is spamblocked. Use wherrera (at) lynxview (dot) com for the reply address.
------------------------------
Date: Wed, 7 Apr 1999 02:58:47 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: Signals Question
Message-Id: <F9stLz.MM8@news.boeing.com>
In article <7edjqp$ckh$1@ultra.sonic.net>,
Jeff Kirk <jeff@co.mendocino.ca.us> wrote:
>Hi,
>
>I have written a script for menuing on our applications box. This keeps our
>users away from the shell prompt and allows them access to their programs.
>I can handle Ctrl-C signals, but my script will die if it recieves a Ctrl-Z.
>How can I control this particular signal? Thanks...
>
Ctrl-Z will generate a SIGTSTP so you can handle or simply
ignore that signal as well.
hth,
--
Charles DeRykus
------------------------------
Date: Mon, 5 Apr 1999 16:54:24 -0400
From: "York Pang" <ypang@graphnet.com>
Subject: This installation make me nut, please help!
Message-Id: <7edb9l$jsm$1@news.graphnet.com>
I installed Perl5.004 on Freebsd 2.2.8 without any problem using default
settings before. But, when I try to install either Perl5.004 or Perl5.005 on
Freebsd 3.1, I am in trouble.
After running "sh Configure", I can successfully build miniperl, but the
process always crashes during the building of extensions. The "make
minitest" runs just fine. I always runs into problems with extensions that
"Always included by default" , such as B, Fcntl, etc. The error messages
are, for example:
...
B.0(.text+0x87cd):undefined reference to xxx
/usr/lib/crt1.0: in function '_start'
/usr/lib/crt2.0(text+0x69):undefined reference to 'Main'
cc:file path prefix 'shareable' never used
Error Code1
Stop
Error Code 1
I tried playing interactively with the Configure, hint file, and even
re-build the Freebsd, but without much difference. I guess that I can turn
off all the extensions referred to the error messages, but that way the
function of Perl maybe problematic.
Does anyone meet this before or successfully install Perl5 on Freebsd 3.1?
Please help!
Your assistance are very much appreciated.
------------------------------
Date: Wed, 07 Apr 1999 10:22:57 +0200
From: GIG <sertim@imaginet.fr>
Subject: User authentication
Message-Id: <370B15E1.8D13A40A@imaginet.fr>
Hello all,
I want a perl script to check a user's navigator basic authentication
but I cannot obtain any information about this authentication through
cgi (ie: AUTH_TYPE and REMOTE_USER environment variables are always
null) although I know that the client navigator sends a proper
WWW-Authenticate http header in response to a 401.
I am using Netscape Enterprise server 3.6 (NT4 sp3).
Any comment appreciated.
Pierre-Olivier Gallut
mailto:sertim@imaginet.fr
------------------------------
Date: Wed, 07 Apr 1999 07:13:15 GMT
From: "IndexFinger.com" <indexfinger@usa.net>
Subject: using "require example.cgi" on NT
Message-Id: <fADO2.381$zE3.10655@typhoon.nycap.rr.com>
When I use the below code on NT, I get an error:
require example.cgi;
But this doesn't:
require "C:\path\to\example.cgi";
Why?
--
========================================================
BigTalker - http://www.bigtalker.com
Want more traffic? Give them a reason to return.
BigTalker - the newest and faster bulletin board system.
------------------------------
Date: 7 Apr 1999 07:40:23 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: using "require example.cgi" on NT
Message-Id: <slrn7gm2v7.o1s.sholden@pgrad.cs.usyd.edu.au>
On Wed, 07 Apr 1999 07:13:15 GMT, IndexFinger.com <indexfinger@usa.net> wrote:
>
>
>When I use the below code on NT, I get an error:
>
>require example.cgi;
Because you forgot the quotes. If you read the error message is should
be reasonably obvious that it is looking for examplecgi...
If you read the documentation and did what it says to do you would run
with warnings enabled (-w) and would have been told about an unquoted string...
--
Sam
Simple rule: include files should never include include files.
--Rob Pike
------------------------------
Date: 12 Dec 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Special: Digest Administrivia (Last modified: 12 Dec 98)
Message-Id: <null>
Administrivia:
Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing.
]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body. Majordomo will then send you instructions on how to confirm your
]subscription. This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.
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 5317
**************************************