[9605] in Perl-Users-Digest
Perl-Users Digest, Issue: 3199 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Jul 19 18:07:19 1998
Date: Sun, 19 Jul 98 15:00:28 -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 Sun, 19 Jul 1998 Volume: 8 Number: 3199
Today's topics:
Re: /^[a-z0-9]/ (Ronald J Kimball)
Re: atomic (Larry Rosler)
Re: Can a Crontab run perl script <barmar@bbnplanet.com>
Re: Can a Crontab run perl script (John Stanley)
convert to text darrensw@pacbell.net
GMTIME darrensw@pacbell.net
Re: GMTIME <minich@globalnet.co.uk>
Re: GMTIME darrensw@pacbell.net
Re: GMTIME (Larry Rosler)
Re: How can I use a $ in s///? <mthomas=posting@edrc.cmu.edu>
Re: How do I clear an array? <tchrist@mox.perl.com>
Re: How do I clear an array? (-)
Re: How to tell if a scalar is a number? <tchrist@mox.perl.com>
Re: How to tell if a scalar is a number? (Eric Harley)
Re: How to tell if a scalar is a number? (Larry Rosler)
Re: How would I associate the alphabet with numbers? (Craig Berry)
Re: How would I associate the alphabet with numbers? (Larry Rosler)
Re: increment operator question (Craig Berry)
Re: increment operator question (Matthew Bafford)
Re: multiple forks??? <spamsux-tex@habit.com>
Re: Oh man, DO I love Perl ! (References to things that (Sean McKenna)
Re: Perl Beautifier Home Page <spamsux-tex@habit.com>
Re: Program to give day of the week from given date (Eric Harley)
Re: Program to give day of the week from given date (-)
Re: Program to give day of the week from given date (Larry Rosler)
Re: Reading in an email message into a Perl program (-)
Re: Restricting refering domains access to script? (Paul Buder)
Re: Restricting refering domains access to script? (-)
Re: Restricting refering domains access to script? <tchrist@mox.perl.com>
Web Components <noSpam@somedomain.com>
Re: Web Components (Larry Rosler)
Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sun, 19 Jul 1998 14:56:47 -0400
From: rjk@coos.dartmouth.edu (Ronald J Kimball)
Subject: Re: /^[a-z0-9]/
Message-Id: <1dcf4kv.1bqtsi3wij0lcN@bay1-52.quincy.ziplink.net>
Jonathan Feinberg <jdf@pobox.com> wrote:
> abigail@fnx.com (Abigail) writes:
>
> > /[^a-z0-9]/
> >
> > But that disallowes A-Z and accented letters as well. Perhaps you want /\W/.
>
> Huh?
>
> print join "\n", grep /^[^a-z0-9]/, qw(apple Brown betty Delight);
>
> Does that not print "Brown\nDelight" on your box?
The original poster is looking for a regex to
"check if there are non-alphanumeric characters in the input".
If he used the above regex, it would indeed catch non-alphanumeric
characters. However, it would also match uppercase and accented
letters. Thus, using the regex as he intended would disallow A-Z and
accented letters, exactly as Abigail said.
if (/[^a-z0-9]/) {
die "Non-alphanumeric characters!\n";
} else {
print "$_ is A-OK!\n";
}
--
_ / ' _ / - aka - rjk@coos.dartmouth.edu
( /)//)//)(//)/( Ronald J Kimball chipmunk@m-net.arbornet.org
/ http://www.ziplink.net/~rjk/
"It's funny 'cause it's true ... and vice versa."
------------------------------
Date: Sun, 19 Jul 1998 11:54:37 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: atomic
Message-Id: <MPG.101be0cbf35f1afa98975e@nntp.hpl.hp.com>
[This followup was posted to comp.lang.perl.misc and a copy was sent to
the cited author.]
In article <35B2064F.4452DC9@g-ol.com> on Sun, 19 Jul 1998 17:44:32
+0300, Maen Suleiman <maen@g-ol.com> says...
> Hi again ,
> i would like toconvert the proccess of reading then writing to a file
> an atomic operation !!
> how can it be done in perl ..
> thanx in advance
Tom Phoenix's answer to your previous question is applicable. You may
also want to look in perlfaq5: "How can I lock a file?" and the
succeeding questions.
--
Larry Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Sun, 19 Jul 1998 19:50:19 GMT
From: Barry Margolin <barmar@bbnplanet.com>
Subject: Re: Can a Crontab run perl script
Message-Id: <%5ss1.8$DF4.275568@cam-news-reader1.bbnplanet.com>
In article <35B1A56C.85E14798@compugen.co.il>,
Avi Rosenberg <avir@compugen.co.il> wrote:
>Also remember that when you run a script from cron, it might be
>executing
>with a different uid than your interactive checks...
If it's running from your own crontab, it should be running with your own
uid.
--
Barry Margolin, barmar@bbnplanet.com
GTE Internetworking, Powered by BBN, Cambridge, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
------------------------------
Date: 19 Jul 1998 21:58:47 GMT
From: stanley@skyking.OCE.ORST.EDU (John Stanley)
Subject: Re: Can a Crontab run perl script
Message-Id: <6otq6n$qai$1@news.NERO.NET>
In article <35b0a302.365763991@news2.cais.com>,
- <root.noharvest.\@not_even\here.com> wrote:
>Wali Haidri <whaidri@ford.com> Said this:
>
>>I wrote a perl (actually an oraperl) program. It runs as expected when
>>submitted from the command line. But when I run it from a crontab, it
>>does not work.
>
>Anywhere in the script where you use "relative" paths, you will need
>to make them full paths.....
That is not true. What you need to do is set your working directory to
whatever your script expects to see when it runs, OR have your script
take care of going to where it wants to be. For executables that are
not already in the limited path that crontab gives you, you need to
either set your path, or use the full path in the system/exec/``
statements.
>open (IN, "somefile.pl");
>
>needs to be changed to
>
>open (IN, "/full/dir/to/somefile.pl");
Not if your crontab entry is (cd /full/dir/to; scriptname). If you are
trying to reuse code so that it does the right thing based on where it
is run from, you do NOT want to hardwire paths.
>"working directory" but when crontab runs it, he's not smart enough to
>know what you want the "working directory" to be, so he uses his
>current directory, which is off somewhere in /usr/sbin land or
>something.
That is simply not true.
------------------------------
Date: Sun, 19 Jul 1998 21:35:36 GMT
From: darrensw@pacbell.net
Subject: convert to text
Message-Id: <35b264e5.20077552@news.pacbell.net>
Hi
I have a script with many subroutines and want to know how to convert
the first item in an array to text which can be used in another
subroutine.
e.g. $thecar[0] is the name of the car. I can run a search in another
part of the program and type the name of the car which produces
certain search results.
What I want to be able to do is run a search for others cars with the
same name from the screen showing the car.
So, in the search sub I am looking for $carname
When I go to the screen showing the car I need to assign $thecar[0] so
that $carname = $thecar[0].
This would be overwritten each time someone displayed a different car,
which is good, and then they can just hit the HREF which takes them to
the search sub but now with a string for $carname.
I hope this is clear enough.
Anybody suggest anything??
Darren
------------------------------
Date: Sun, 19 Jul 1998 19:23:13 GMT
From: darrensw@pacbell.net
Subject: GMTIME
Message-Id: <35b24611.12184108@news.pacbell.net>
Hi
I am trying to configure a script to include the time in GMTIME. (GMT)
I have replaced the localtime variable with gmtime but it is 1 hour
out. How does this happen? Is it the time on the host server?
Thanks all
Darren
------------------------------
Date: Sun, 19 Jul 1998 21:36:54 +0100
From: "Martin" <minich@globalnet.co.uk>
Subject: Re: GMTIME
Message-Id: <6otlam$k6b$1@heliodor.xara.net>
>I have replaced the localtime variable with gmtime but it is 1 hour
>out. How does this happen? Is it the time on the host server?
Are we still in British Summer Time? If so, then that'll be the hour
we added on.
Martin
------------------------------
Date: Sun, 19 Jul 1998 20:45:56 GMT
From: darrensw@pacbell.net
Subject: Re: GMTIME
Message-Id: <35b25ab0.17463354@news.pacbell.net>
On Sun, 19 Jul 1998 21:36:54 +0100, "Martin" <minich@globalnet.co.uk>
wrote:
>>I have replaced the localtime variable with gmtime but it is 1 hour
>>out. How does this happen? Is it the time on the host server?
>
>
>Are we still in British Summer Time? If so, then that'll be the hour
>we added on.
>
>Martin
>
No,if it is 12noon PST in the US then it is 20:00 (8:00pm) in the UK.
Any more suggestions??
Darren
------------------------------
Date: Sun, 19 Jul 1998 14:36:33 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: GMTIME
Message-Id: <MPG.101c06b95e7edb9e989762@nntp.hpl.hp.com>
[This followup was posted to comp.lang.perl.misc and a copy was sent to
the cited author.]
In article <35b25ab0.17463354@news.pacbell.net> on Sun, 19 Jul 1998
20:45:56 GMT, darrensw@pacbell.net <darrensw@pacbell.net> says...
> On Sun, 19 Jul 1998 21:36:54 +0100, "Martin" <minich@globalnet.co.uk>
> wrote:
>
> >>I have replaced the localtime variable with gmtime but it is 1 hour
> >>out. How does this happen? Is it the time on the host server?
> >
> >Are we still in British Summer Time? If so, then that'll be the hour
> >we added on.
> >
> >Martin
> >
> No,if it is 12noon PST in the US then it is 20:00 (8:00pm) in the UK.
>
> Any more suggestions??
>
> Darren
But if it is 12noon P*D*T in the US then it is 20:00 (8:00pm) in the UK
(BST), but it is 19:00 GMT (UTC).
--
Larry Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Sun, 19 Jul 98 14:14:02 EDT
From: Mark Thomas <mthomas=posting@edrc.cmu.edu>
Subject: Re: How can I use a $ in s///?
Message-Id: <wf1r9zhu2s5.fsf@disorder.ices.cmu.edu>
In article <MPG.101af9fb7eede08a98975a@nntp.hpl.hp.com>, Larry Rosler writes:
> Within the character class, the characters lose most of their
> metacharacter meanings. It ends up like this:
> s/([@!#%&{}\-=,;<>\/$*()+[\]])/\@$1/g;
> where the only characters with special meanings are '-' (range, though
> that could be fixed by making it the last character in the class), '/'
> (regex delimiter, though that could be fixed by changing the delimiter,
> to '|' for example), and ']' (end-of-class delimiter, though that could
> be fixed by making it the first character in the class).
Variable interpolation still occurs inside the character class, so
you'll also need to escape $ since $ followed by a "funny character"
usually has a special meaning. This makes your substitution:
s/([@!#%&{}\-=,;<>\/\$*()+[\]])/\@$1/g;
One way to test this is to run the regexp on itself, and you'll get
s@/@(@[@@@!@#@%@&@{@}\@-@=@,@;@<@>\@/\@$@*@(@)@+@[\@]@]@)@/\@@@$1@/g@;
Although I don't know if this is applicable to the original problem,
you can escape all non-whitespace, non-word characters using the
following:
s/([^\s\w])/\@$1/g;
-Mark
--
Mark Thomas Engineering Design Research Center; Carnegie Mellon
http://www.ndim.edrc.cmu.edu/~mthomas/
------------------------------
Date: 19 Jul 1998 17:50:28 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: How do I clear an array?
Message-Id: <6otbl4$chb$1@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc,
cberry@cinenet.net (Craig Berry) writes:
:Yeah, looks like you're right -- I was extrapolating (falsely, it turns
:out) from the warning given for use of an undef scalar. O Perl Gurus, how
:come
: print $foo;
:for undefined $foo gives a 'use of uninitialized value' warning, but
: print @foo;
:for undefined @foo doesn't?
The notion of an aggregate being "undefined" has little sense.
% man perlfunc
Currently, using defined() on an entire array or hash reports whether
memory for that aggregate has ever been allocated. So an array you
set to the empty list appears undefined initially, and one that once
was full and that you then set to the empty list still appears defined.
You should instead use a simple test for size:
if (@an_array) { print "has array elements\n" }
if (%a_hash) { print "has hash members\n" }
Using undef() on these, however, does clear their memory and then
report them as not defined anymore, but you shoudln't do that unless
you don't plan to use them again, because it saves time when you load
them up again to have memory already ready to be filled.
The undefined value is a scalar notion.
--tom
--
It is, of course, written in Perl. Translation to C is left as an
exercise for the reader. :-) --Larry Wall in <7448@jpl-devvax.JPL.NASA.GOV>
------------------------------
Date: Sun, 19 Jul 1998 20:33:14 GMT
From: root.noharvest.\@not_even\here.com (-)
Subject: Re: How do I clear an array?
Message-Id: <35b25680.65014171@news2.cais.com>
lr@hpl.hp.com (Larry Rosler) Said this:
>[This followup was posted to comp.lang.perl.misc and a copy was sent to
>the cited author.]
>
>In article <1dcdph3.1xne7e1lv8esaN@bay2-83.quincy.ziplink.net> on Sat, 18
>Jul 1998 20:34:44 -0400, Ronald J Kimball <rjk@coos.dartmouth.edu>
>says...
>> Craig Berry <cberry@cinenet.net> wrote:
>>
>> > Not true (to my way of thinking). 'undef @array' says "I'm entirely done
>> > with @array; nuke it," while '@array = ()' says "@array is still around,
>> > it just doesn't contain anything right now." That's a big (semantic)
>> > distinction. And if I mean "it's empty now" but use undef to get there, I
>> > get "use of undefined value" warnings (quite properly).
>>
>> I wasn't able to reproduce this behavior. Could you post a bit of code
>> that shows how @array = () gives different warnings than undef @array?
>
>I tried evaluating 'scalar @array' and $#array, and got 0 and -1
>respectively in each case as expected, but no 'use of undefined' warning
>for the undef case. I'm surprised.
>
Exactly - The resulting internal representations (which I will admit,
I have no real knowledge of) should be the same for each method of
undefining an array.
undef(VAR) undefines the value of VAR. It doesn't undefine the
declared variable, but simply the value of said variable. That's the
same thing @array = () does, does it not? In either case, @array
still exists, but represents an empty string.
Also, consider that, if you need this feature, undef() is nice enough
to return the value that you just undefine (at least, I think it
does... this statement is somewhat ambiguous - "the undefined value is
returned" - it could mean the value that signifies "undefined" is
returned (0), or it could mean the value that was cleared is returned)
------------------------------
Date: 19 Jul 1998 19:42:57 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: How to tell if a scalar is a number?
Message-Id: <6oti81$i48$1@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc, Paul Tomko <tomko@xnet.com> writes:
:I admit to being a former C programmer. I am trying to determine the
:easiest way to determine if a scalar contains all digits, or if it
:compares some non-digit characters ; without of course, printing it out
:and looking at it.
Not used to regular expressions, eh? This is FAQ. See perlfaq4.
Also, see perldata.
--tom
--
"For it, that's now" --Larry Wall
------------------------------
Date: Sun, 19 Jul 1998 13:28:34 -0700
From: eharley@pacbell.net (Eric Harley)
Subject: Re: How to tell if a scalar is a number?
Message-Id: <eharley-1907981328340001@ppp-207-214-149-190.snrf01.pacbell.net>
In article <6oti81$i48$1@csnews.cs.colorado.edu>, tchrist@mox.perl.com
(Tom Christiansen) wrote:
Try that regexp on for size.
while (<>) {
chomp;
if (/^[-+]?(([0-9]+)|([0-9]*\.[0-9]+)([eE][+-]?[0-9]+)?)$/) {
print "$_ number\n";
} else {
print "$_ not number\n";
}
}
> [courtesy cc of this posting sent to cited author via email]
>
> In comp.lang.perl.misc, Paul Tomko <tomko@xnet.com> writes:
> :I admit to being a former C programmer. I am trying to determine the
> :easiest way to determine if a scalar contains all digits, or if it
> :compares some non-digit characters ; without of course, printing it out
> :and looking at it.
>
> Not used to regular expressions, eh? This is FAQ. See perlfaq4.
> Also, see perldata.
>
> --tom
> --
> "For it, that's now" --Larry Wall
--
Eric Harley
Freelance Programmer
You need it done, I'm your man.
eharley@pacbell.net
http://burn.victim.com/~eharley
------------------------------
Date: Sun, 19 Jul 1998 14:54:00 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: How to tell if a scalar is a number?
Message-Id: <MPG.101c0ad0fef7ac16989763@nntp.hpl.hp.com>
[This followup was posted to comp.lang.perl.misc and a copy was sent to
the cited author.]
In article <eharley-1907981328340001@ppp-207-214-149-
190.snrf01.pacbell.net> on Sun, 19 Jul 1998 13:28:34 -0700, Eric Harley
<eharley@pacbell.net> says...
> In article <6oti81$i48$1@csnews.cs.colorado.edu>, tchrist@mox.perl.com
> (Tom Christiansen) wrote:
>
> Try that regexp on for size.
>
> while (<>) {
> chomp;
> if (/^[-+]?(([0-9]+)|([0-9]*\.[0-9]+)([eE][+-]?[0-9]+)?)$/) {
> print "$_ number\n";
> } else {
> print "$_ not number\n";
> }
> }
Your quoting makes it appear as if Tom C wrote that regex. He didn't.
He simply referred to the regex in the FAQ, which works. Yours doesn't.
Try
$_ = '1.';
for example.
--
Larry Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 19 Jul 1998 17:11:27 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: How would I associate the alphabet with numbers?
Message-Id: <6ot9bv$85r$4@marina.cinenet.net>
Chocolate (poohba@io.com) wrote:
: I would like to make a=100000 and b=200000 and c=300000... How would I do
: this?
I'd recommend doing this with hash vals rather than scalars, makes things
a bit more tractable. Here's how I'd do it:
@dict{'a'..'z'} = map { $_ * 100000 } ( 1..26 );
Then $dict{a} is 100000, $dict{b} is 200000, and so forth.
: what I want is
:
: if a=100000 then a00001 = 100001;
I can't make sense of that syntax. Could you try again, writing it in
more Perlish pseudocode?
---------------------------------------------------------------------
| Craig Berry - cberry@cinenet.net
--*-- Home Page: http://www.cinenet.net/users/cberry/home.html
| Member of The HTML Writers Guild: http://www.hwg.org/
"Every man and every woman is a star."
------------------------------
Date: Sun, 19 Jul 1998 12:12:48 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: How would I associate the alphabet with numbers?
Message-Id: <MPG.101be50ee748234398975f@nntp.hpl.hp.com>
[This followup was posted to comp.lang.perl.misc and a copy was sent to
the cited author.]
In article <Pine.BSF.3.96.980719113942.19213A-100000@dillinger.io.com> on
Sun, 19 Jul 1998 11:47:20 -0500, Chocolate <poohba@io.com> says...
> I would like to make a=100000 and b=200000 and c=300000... How would I do
> this?
> what I want is
>
> if a=100000 then a00001 = 100001;
>
> so if I put in a number of a54856 it should say
Assuming your string is in $_,
s/^([a-z])/ord($1) - ord('a') + 1/e;
This replaces a lower-case letter if it is the first character of the
string by its ordinal value relative to 'a' == 1, and leaves the rest of
the string unchanged.
`perldoc perlre` will help you understand this and much more.
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
> _/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
>
> _/_/_/ _/ _/
> _/ _/ _/ _/
> Web Page Designs _/_/_/ _/_/_/ _/_/_/ _/_/_/ _/_/_/ _/_/_/
> Small Programs _/ _/ / _/ _/ _/ _/ _/ _/ _/ _/ poohba@io.com
> www.io.com/~poohba _/ _/_/_/ _/_/_/ _/ _/ _/_/_/ _/_/\_ (919)506-5883
>
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
> _/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
You have been asked previously to observe Usenet etiquette by restricting
your signature to four lines. How about it?
--
Larry Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 19 Jul 1998 16:52:40 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: increment operator question
Message-Id: <6ot88o$85r$3@marina.cinenet.net>
wings (xuchu@iscs.nus.edu.sg) wrote:
: When I am reading PP(P79), it gives an example
: on autoincrement operator ++:
:
: print ++($foo='zz'); #prints 'aaa'
:
: I tried it and it's true. but i cant understand
: why two 'z's will become three 'a's. Where's the
: 3rd 'a' from? it's like mathematics that has
: 'borrow' effect?
s/borrow/carry/, but yes, that's exactly right. Magic autoincrement on
letter strings acts like base-26 addition on the digits a-z.
---------------------------------------------------------------------
| Craig Berry - cberry@cinenet.net
--*-- Home Page: http://www.cinenet.net/users/cberry/home.html
| Member of The HTML Writers Guild: http://www.hwg.org/
"Every man and every woman is a star."
------------------------------
Date: Sun, 19 Jul 1998 20:36:36 GMT
From: dragons@scescape.net (Matthew Bafford)
Subject: Re: increment operator question
Message-Id: <MPG.101c11fe1f9423da989688@news.scescape.net>
In article <6ot4kp$rcr6@id4.nus.edu.sg> on 19 Jul 1998 15:50:49
GMT, wings (a) felt the following information to be of use:
> Hi, folks:
>
> When I am reading PP(P79), it gives an example
> on autoincrement operator ++:
>
> print ++($foo='zz'); #prints 'aaa'
>
> I tried it and it's true. but i cant understand
> why two 'z's will become three 'a's. Where's the
> 3rd 'a' from? it's like mathematics that has
> 'borrow' effect?
Like the book says:
...the increment is done as a string, preserving each
character within its range, with carry:
____________________________^^^^^^^^^^
Hope this helps!
--Matthew
------------------------------
Date: Sun, 19 Jul 1998 13:46:24 +0800
From: Austin Schutz <spamsux-tex@habit.com>
Subject: Re: multiple forks???
Message-Id: <35B18830.4CBF@habit.com>
> > Hey All:
> >
> > I am wondering how I can spawn multiple children from 1 parent? I am
> > comfortable with one child process, but multiple is giving me problems.
> > I
> > want to run a synchronous row/column sort on a matrix. Any basic
> > multiple
> > process pointers would be great.
> >
>
While this is not an impossible task doing fork() it would
probably be _much_ faster to grab the beta of perl 5.005 and read up
on the new thread stuff.
I haven't looked at it yet, but in general it takes a fair amount of
time/resources each time you fork(). Threads are more efficient in this
respect and should be more applicable to your situation.
Also (at least this has been my experience) you don't gain much,
if anything, by parallelizing your activity unless you have multiple
processors. YMMV.
Austin
------------------------------
Date: Sun, 19 Jul 1998 18:03:53 GMT
From: sean@mckennaprod.com (Sean McKenna)
Subject: Re: Oh man, DO I love Perl ! (References to things that go out of scope)
Message-Id: <35b23404.6440643@nntp1.ba.best.com>
On Sun, 19 Jul 1998 00:02:40 -0400, "Matthew O. Persico"
<mpersico@erols.com> wrote:
>For the uninitiated, could you supply the title ad maybe the ISBN. I
>fear that asking for "Nigel Chapman's" book at your local comupter book
>seller might not cut it.
Perl: The Programmer's Companion, John Wiley & Sons; ISBN: 047197563X
Far and away one of the best Perl books I have seen. Written for
folks with a programming background and some experience in other
languanges.
Sean McKenna "All the world's a stage..."
------------------------------
Date: Sun, 19 Jul 1998 13:33:05 +0800
From: Austin Schutz <spamsux-tex@habit.com>
Subject: Re: Perl Beautifier Home Page
Message-Id: <35B18511.1EF6@habit.com>
Zenin wrote:
>
> Russ Allbery <rra@stanford.edu> wrote:
> >snip<
> : That's unnecessarily long for most people's version numbers. Try this
> : instead. :)
> : ($VERSION = (split (' ', q$Revision: 1.2 $ ))[1]) =~ s/\.(\d)$/.0$1/;
>
> Try that with 1.2.1 or 1.100 and you'll get burned hard.
But the whole point of doing something like
($VERSION = (split (' ', q$Revision: 1.2 $ ))[1]) =~s/\.(\d)$/.0$1/;
is so that if it fails no one will understand why anyway. If
you wanted it to be understood and work reliably you would just do
$VERSION = "1.2.1";
and be done with it. But that's not very elite.
Austin
-----
print "Obfuscation defeats laziness\n";
------------------------------
Date: Sun, 19 Jul 1998 12:14:58 -0700
From: eharley@pacbell.net (Eric Harley)
Subject: Re: Program to give day of the week from given date
Message-Id: <eharley-1907981214580001@ppp-207-214-149-26.snrf01.pacbell.net>
In article <35B153C6.D0620A7D@acm.org>, melinda@acm.org wrote:
But what if you don't have the date command.
print (Sun,Mon,Tue,Wed,Thu,Fri,Sat)[(localtime)][6];
Shamelessly taken from the Camel Book P. 185
> Here's what worked for me (refer also to man page "date":
> #!/usr/bin/perl -w
> #--This uses Linux system command "date" with
> #-- optional formatting
> $DateDay = `date -d 16-July-1998 '+%A'`;
> print ("DateDay is $DateDay \n");
> Melinda Quinn melinda@acm.org
> ==============================================
> Hari Patel wrote:
> Does anybody know how to output day of teh week for a given date
> > in perl
> e.g. if you have date as 13/5/98 pass it to some function which
> > would output
> > Wednesday........
> > Please email me with any suggestions
> > hari.patel@bt.com
> > Many thanks - hari
--
Eric Harley
Freelance Programmer
You need it done, I'm your man.
eharley@pacbell.net
http://burn.victim.com/~eharley
------------------------------
Date: Sun, 19 Jul 1998 20:53:56 GMT
From: root.noharvest.\@not_even\here.com (-)
Subject: Re: Program to give day of the week from given date
Message-Id: <35b25c45.66438163@news2.cais.com>
"Quinn,M" <melinda@acm.org> Said this:
>Here's what worked for me (refer also to man page "date":
> #!/usr/bin/perl -w
> #--This uses Linux system command "date" with
> #-- optional formatting
> $DateDay = `date -d 16-July-1998 '+%A'`;
> print ("DateDay is $DateDay \n");
>Melinda Quinn melinda@acm.org
>==============================================
>Hari Patel wrote:
> Does anybody know how to output day of teh week for a given date
>> in perl
> e.g. if you have date as 13/5/98 pass it to some function which
>> would output
>> Wednesday........
>> Please email me with any suggestions
>> hari.patel@bt.com
>> Many thanks - hari
Want the day of the week? or the number of that day of the week?
It's all in localtime() - one way or the other:
($sec, $min, $hour, $mday, $mon, $yr, $wday, $yday, $isdst) =
localtime(time);
@days = ("Sunday", "Monday", "Tuesday", "Wednedsday", "Thursday",
"Friday", "Saturday");
$weekday = $days[$wday];
For example, if you ran this snippet on monday, the value of $wday
would be 1, and $weekday would be Monday.
Obviously you can modify the list @days so it's Mon, or Monday or
whatever.
------------------------------
Date: Sun, 19 Jul 1998 14:14:36 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Program to give day of the week from given date
Message-Id: <MPG.101c0197facca227989760@nntp.hpl.hp.com>
[This followup was posted to comp.lang.perl.misc and a copy was sent to
the cited author.]
In article <eharley-1907981214580001@ppp-207-214-149-
26.snrf01.pacbell.net> on Sun, 19 Jul 1998 12:14:58 -0700, Eric Harley
<eharley@pacbell.net> says...
> In article <35B153C6.D0620A7D@acm.org>, melinda@acm.org wrote:
>
> But what if you don't have the date command.
>
> print (Sun,Mon,Tue,Wed,Thu,Fri,Sat)[(localtime)][6];
>
> Shamelessly taken from the Camel Book P. 185
Shamelessly perhaps, but accurately not. I don't have the Camel at home,
but there are two errors in that statement as it stands, and a third if
you 'use strict;'.
print +(Sun,Mon,Tue,Wed,Thu,Fri,Sat)[(localtime)[6]];
print +(qw(Sun Mon Tue Wed Thu Fri Sat))[(localtime)[6]];
--
Larry Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Sun, 19 Jul 1998 20:48:46 GMT
From: root.noharvest.\@not_even\here.com (-)
Subject: Re: Reading in an email message into a Perl program
Message-Id: <35b25916.65622448@news2.cais.com>
rjk@coos.dartmouth.edu (Ronald J Kimball) Said this:
>Larry Rosler <lr@hpl.hp.com> wrote:
>> Please enlighten about this portion of this code. "If the name of the
>> header is more than one character long, use it as the key for the value
>> of the header. Otherwise [is it then just a ':'?] concatenate a space
>> and the value to the existing value (if any)." Will this do everything
>> needed, such as multiple addresses? Hmmm...
First, I goofed.... I snipped the code from a script I'm currently
developing, as opposed to the original working script:
while (<>) # Get headers
{
last if /^$/;
push(@headers, $_);
$header .= $_;
($field, $value) = /^(\S*)\s*(.*)/;
if (length($field) > 1) { $fields{$field} = $value; }
else { $fields{$field} .= " $value"; }
}
the $header .= $_; part was missing. Of course, for most usage, both
the $header = ""; and $header .= $_; can be removed entirely - it
simply enables you to quickly write out the message to the mail spool
file directly rather than continue with the filtering routines (a
"pass through" sort of thing inside your mail filters) like this:
open (OUT, ">$mailspool");
print $header;
print "\n";
print $body;
close OUT;
rather than having to do a foreach through %fields. Just a shortcut.
>
>I believe he is dealing with multi-line headers, such as:
>
>X-Face: *spJTl5BP|H]tv^0$Q6a-pzBFK8I5fHa$8}}%f[=uE!o{BT`.GS9L}atGt.A*
> lE.l,Qi{"Ge2>hK*$qvJx\ev\>+b87D,fxSfXItRacBv*Z%`bZK*@B
>
>On the first line, the regex match sets $field to 'X-Face:' and $value
>to '*spJTl5BP|H]tv^0$Q6a-pzBFK8I5fHa$8}}%f[=uE!o{BT`.GS9L}atGt.A*'.
>
>The length of $field is greater than 1, so the hash now looks like
>
>(
> 'X-Face:' =>
> '*spJTl5BP|H]tv^0$Q6a-pzBFK8I5fHa$8}}%f[=uE!o{BT`.GS9L}atGt.A*',
>)
>
>On the second line, the regex match sets $field to '' and $value to
>'lE.l,Qi{"Ge2>hK*$qvJx\ev\>+b87D,fxSfXItRacBv*Z%`bZK*@B'.
>
>The length of $field is not greater than 1, so the value should be
>concatenated to the hash value of the previous field. Unfortunately,
>the name of the previous field has been replaced with '', so the hash
>now looks like
>
>(
> 'X-Face:' =>
> '*spJTl5BP|H]tv^0$Q6a-pzBFK8I5fHa$8}}%f[=uE!o{BT`.GS9L}atGt.A*',
> '' =>
> ' lE.l,Qi{"Ge2>hK*$qvJx\ev\>+b87D,fxSfXItRacBv*Z%`bZK*@B',
>)
>
>The first line of each field will be associated with the proper key, but
>any subsequent lines in multiline fields will be appended to the value
>of the null string key.
>
>Even if it did work properly, the multiline headers would be slightly
>munged, as newlines would be replaced with spaces.
>
Exactly. This isn't perfect... But generally those header fields
that are "multiline" or even repeated with different values
(Recieved:) aren't critical for general email manipulations. Usually
you are looking for the value of From:, To:, Subject:, or contents of
the body. If you need more, this isn't the best solution - but I've
been using the above code for about 2 years and it serves most needs.
>> Could you possibly have had a different condition in mind, along the
>> lines of:
>> if (!exists $fields{$field}) ...
>
>His condition did make sense for what he was trying to do. I missed the
>other problem, which your text above revealed. Some headers appear more
>than once, such as 'Received:', but his script will only save the last
>occurence.
>
>
>> Could you possibly have tested this code before posting it for the world
>> to see?
>
>I think we can assume he didn't. It was a good starting point, although
>not quite ready for posting.
Other than the little problem of forgetting the $header .= $_; line,
this works beautifully. It was very much ready for posting.
Like i mentioned above, I've been using this for 2 years, and I've
never had it "break" in any way. Of course, I'm not keying into the
Received: lines or any other multiline header data. If you need to
know who the message was from, or who it was to, or the subject, this
will let you compare that information.
And, as far as multiple addresses, it should work.... I've never seen
To: oneuser@somewhere.com
To: twouser@somewhere.com
To: threeuser@somewhere.com
but rather,
To: oneuser@somewhere.com, twouser@somewhere.com,
threeuser@somewhere.com
(and even though it wrapped, threeuser is still not seperated by a
newline, so it's still the same field, same line.)
------------------------------
Date: Sun, 19 Jul 1998 19:01:46 GMT
From: paulb@user1.teleport.com (Paul Buder)
Subject: Re: Restricting refering domains access to script?
Message-Id: <6otfqh$ph4$1@user1.teleport.com>
In <6oq9c0$o3t$1@csnews.cs.colorado.edu> Tom Christiansen <tchrist@mox.perl.com> writes:
>Alas, there is no such thing as a `refering [sic] domain'! The word is
>`referring'. The writers of the HTTP docs don't seem to have been able
>to spell, or to spell-check.
>--tom
> averring conferring deferring deterring disinterring erring herring
> inerring inferring interring preferring referring transferring
> underring undeterring unerring
boring
Well not really, it was fun but I had to throw that in.
------------------------------
Date: Sun, 19 Jul 1998 20:24:13 GMT
From: root.noharvest.\@not_even\here.com (-)
Subject: Re: Restricting refering domains access to script?
Message-Id: <35b25572.64744260@news2.cais.com>
Tom Christiansen <tchrist@mox.perl.com> Said this:
>Alas, there is no such thing as a `refering [sic] domain'! The word is
>`referring'. The writers of the HTTP docs don't seem to have been able
>to spell, or to spell-check.
>
>--tom
>
> averring conferring deferring deterring disinterring erring herring
> inerring inferring interring preferring referring transferring
> underring undeterring unerring
>
Fine... but is that pertinent? I'm sure you know exactly what he
wants.
Also, don't forget, many people who use usenet are not "native english
speakers" - often americans, the provincial little people that we are,
fail to realize this. Or maybe it's that americans feel intimidated
by the fact that most non-americans can speak more than one language
at all??
------------------------------
Date: 19 Jul 1998 21:21:06 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Restricting refering domains access to script?
Message-Id: <6oto02$nkv$1@csnews.cs.colorado.edu>
In comp.lang.perl.misc, some idiot who screws up his address writes:
:Or maybe it's that americans feel intimidated
:by the fact that most non-americans can speak more than one language
:at all??
You obviously don't know me very well. I do not to the category you
seem to think I do. Hint: my first undergraduate degree was in a
language that isn't English.
--tom
--
There's no such thing as a simple cache bug. --Rob Pike
------------------------------
Date: Sun, 19 Jul 1998 15:44:56 -0700
From: New Book News <noSpam@somedomain.com>
Subject: Web Components
Message-Id: <35B276E8.D828C6CF@somedomain.com>
Programming Web Components
By Reaz Hoque and Tarun Sharma
This book/CD-ROM package shows you how to build killer apps that not
only run on a Web
browser but also work as stand-alone applications, independent of all
platforms. Java Masters Reaz
Hoque and Tarun Sharma bring you up to speed on the fundamentals of Java
and distributed
objects. They'll show you how to use JavaBeans and ActiveX, and help you
determine which works
better for your particular situation. You'll also learn how to link the
two technologies using JavaSoft's
ActiveX and JavaBeans bridge wrapper tools - and you'll even enjoy rare
guidance on how to
combine VRML with JavaBeans. The included CD-ROM gives you all this:
Beans Developers Kit
(BDK) Version 1.0, IBM's VisualAge for Java, Super Mojo, and other
third-party Beans and
ActiveX controls. You also get MindQ's interactive Java tutorial [a $50
value for free]. Visit the official
book site: http://www.rhoque.com/javabeans/.
Web Developer Magazine wrote:
"If you're trying to keep up with emerging Web technologies, starting to
learn how to create your
own data aware controls, learning about COM objects, or are just
interested in how the Web is
going to work in the future, you won't be appointed with this book. Reaz
Hoque and Tarun Sharma
have done an excellent job writing this book. "
Buy it online:
http://www.amazon.com/exec/obidos/ISBN%3D0079123163/reazhoqueA/002-8026182-4000044
------------------------------
Date: Sun, 19 Jul 1998 14:58:01 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Web Components
Message-Id: <MPG.101c0bc4238946a3989764@nntp.hpl.hp.com>
In article <35B276E8.D828C6CF@somedomain.com> on Sun, 19 Jul 1998
15:44:56 -0700, New Book News <noSpam@somedomain.com> says...
blah, blah, blah about some product that doesn't even have the word Perl
in hundreds of words of blurb. And with a 'noSpam' in your bogus email
address, at that!
Please spam somewhere else.
--
Larry Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 12 Jul 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 Mar 98)
Message-Id: <null>
Administrivia:
Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.
If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu.
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 3199
**************************************