[8645] in Perl-Users-Digest
Perl-Users Digest, Issue: 2262 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Apr 6 23:07:15 1998
Date: Mon, 6 Apr 98 20:00:25 -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 Mon, 6 Apr 1998 Volume: 8 Number: 2262
Today's topics:
Re: Any ideas, expert opinions?? about.. <eugene@vertical.net>
Re: Buggy textarea using IE (Robert Prashad)
Re: Buggy textarea using IE <matt@whiterabbit.co.uk>
Re: Buggy textarea using IE <eugene@vertical.net>
Re: contexts: is there such a thing as array? <rjk@coos.dartmouth.edu>
Re: Determining which flock strategy perl is using <rootbeer@teleport.com>
Re: easy way to enable perl script setuid? <rootbeer@teleport.com>
Re: How do I strip newlines from a var <rootbeer@teleport.com>
Re: How do I strip newlines from a var <ljz@asfast.com>
How to call a function every 15 seconds or so ? (Michael Shavel)
Re: How to call a function every 15 seconds or so ? (Martien Verbruggen)
HTTP/1.0 200 OK : What's it mean??? <rmccollu@inet.net>
Re: HTTP/1.0 200 OK : What's it mean??? (Jason Gloudon)
Re: I need latest perl for HPUX, AIX, Solaris <rootbeer@teleport.com>
Re: If "=~" means match what is doesn't match? <rootbeer@teleport.com>
Re: If "=~" means match what is doesn't match? (Martien Verbruggen)
Re: If "=~" means match what is doesn't match? (Ethan H. Poole)
Re: internationalisation of MacPerl (Paul J. Schinder)
Re: Is there a "Newsgroup" for Newbies to Perl? <rjk@coos.dartmouth.edu>
Re: Is there a "Newsgroup" for Newbies to Perl? <rjk@coos.dartmouth.edu>
Re: Need Reg Expr to yield today's cron jobs (Abigail)
Re: Need Reg Expr to yield today's cron jobs <eugene@vertical.net>
Re: ORA Perl Conference Poll (Jeff Yoak)
Password of the day <snx@snx.com>
perl login problem <jay.blaise@clear.net.nz>
Re: Seek and Read (Andrew M. Langmead)
Re: Seek and Read <sidney@acpub.duke.edu>
Re: Seek and Read (Andrew M. Langmead)
Socket problems! <support@webhot.dk>
Re: using modules (Andrew M. Langmead)
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 06 Apr 1998 20:47:22 -0500
From: Eugene Sotirescu <eugene@vertical.net>
Subject: Re: Any ideas, expert opinions?? about..
Message-Id: <352985A8.B6DB8518@vertical.net>
What's with all these cranky replies lately, Abigail?
You filling in for Tom Christiansen?
Eugene
Abigail wrote:
> Lalit Jairath (ljairath@wright.aps.uoguelph.ca) wrote on MDCLXXIX
> September MCMXCIII in <URL: news:6gap71$p0o$2@ccshst05.cs.uoguelph.ca>:
> ++
> ++ Q: i've an HTML text file- ~/gev.html part of which looks like as below.
> ++ (the original text, pl. see below).
> ++
> ++ Please, read the entire e-mail before replying!
> ++
> ++ Every month we update the HTML text file (~/gev.html) wiht new information
> ++ and we have to
> ++ replace the value of the checked month (e.g. April here) with the value
> ++ of the new month (e.g. in next month April will be replaced by May).
> ++
> ++ Also, we've to add another line (pull down) for April, the replaced month
> ++ (unchecked now). So, the new file should look like as below.
> ++
> ++ (Please see both the original and updated text (as it should look) below.
> ++
> ++
> ++ i've to do this at several places in the file and for several files.
>
> How uninteresting. Sounds like a simple job.
>
> Now, what exactly is your question?
>
> Abigail
> --
> perl -wleprint -eqq-@{[ -eqw\\- -eJust -eanother -ePerl -eHacker -e\\-]}-
------------------------------
Date: Mon, 06 Apr 1998 23:24:20 GMT
From: e0fl26ow@mail.erin.utoronto.ca (Robert Prashad)
Subject: Re: Buggy textarea using IE
Message-Id: <352a6347.487152@news.interlog.com>
If you can't answer the question, then instead of giving a
smart ass response leave it for someone else who can. The scirpt that
saves the form is Perl, why do you think I'm posting to this
newsgroup. Does anyone else know a Perl solution to this problem?
On Sun, 05 Apr 1998 21:45:24 -0500, Eugene Sotirescu
<eugene@vertical.net> wrote:
> I can't answer your question, I only do Perl. Maybe post it on a MS
>Newsgroup?
>
>(Does anyone know how to prevent posts like these from getting
>inserted into a Perl Newsgroup?
>
> Your help is much appreciated.)
>
>
>Robert Prashad wrote:
>
>> I have a script that saves forms to a file. It works great
>> with Navigator. However, Internet Explorer inserts ^M~nl~ into every
>> textarea regardless of the user typing in text or not. The ^M shows up
>> as just a box.
>> Does anyone know how I can prevent these from getting
>> inserted?
>>
>> Your help is much appreciated.
>>
>> Rob
>
>
>
------------------------------
Date: Tue, 07 Apr 1998 01:24:03 +0100
From: Matt Pryor <matt@whiterabbit.co.uk>
To: Robert Prashad <e0fl26ow@mail.erin.utoronto.ca>
Subject: Re: Buggy textarea using IE
Message-Id: <35297223.8B53FC06@whiterabbit.co.uk>
Hi Robert,
(Think that last post might just start a flame war...oh well...)
I'm not sure why IE inserts that... I've never encountered it before...
Are you using clientside Javascript to alter the textarea contents at
all?
However, you could work around the problem by putting something like
this in your Perl source:
$textarea =~ s/\^M~nl~//g;
Better to find out why it's happening, though, than just treat the
symptom.
Robert Prashad wrote:
>
> I have a script that saves forms to a file. It works great
> with Navigator. However, Internet Explorer inserts ^M~nl~ into every
> textarea regardless of the user typing in text or not. The ^M shows up
> as just a box.
> Does anyone know how I can prevent these from getting
> inserted?
>
> Your help is much appreciated.
>
> Rob
--
http://www.whiterabbit.co.uk/design
------------------------------
Date: Mon, 06 Apr 1998 21:06:29 -0500
From: Eugene Sotirescu <eugene@vertical.net>
Subject: Re: Buggy textarea using IE
Message-Id: <35298A22.BC9CE8D@vertical.net>
Often bad posts get bad answers, though I should have known better.
My apologies.
But note that the word Perl isn't mentioned anywhere in your post (and there
are plenty of people posting non-Perl questrions here, so there'sno
telling). Also you don't provide any code. So the only conclusion I could
draw is that this is a IE indiosyncrasy (since it works in Navigator).
Therefore not a Perl question and something that could be better addressed
in an IE newsgroup.
Does this sound unreasonable to you?
I'll guess I'l shut up now and let others answer it.
Eugene
Robert Prashad wrote:
> If you can't answer the question, then instead of giving a
> smart ass response leave it for someone else who can. The scirpt that
> saves the form is Perl, why do you think I'm posting to this
> newsgroup. Does anyone else know a Perl solution to this problem?
>
> On Sun, 05 Apr 1998 21:45:24 -0500, Eugene Sotirescu
> <eugene@vertical.net> wrote:
>
> > I can't answer your question, I only do Perl. Maybe post it on a MS
> >Newsgroup?
> >
> >(Does anyone know how to prevent posts like these from getting
> >inserted into a Perl Newsgroup?
> >
> > Your help is much appreciated.)
> >
> >
> >Robert Prashad wrote:
> >
> >> I have a script that saves forms to a file. It works great
> >> with Navigator. However, Internet Explorer inserts ^M~nl~ into every
> >> textarea regardless of the user typing in text or not. The ^M shows up
> >> as just a box.
> >> Does anyone know how I can prevent these from getting
> >> inserted?
> >>
> >> Your help is much appreciated.
> >>
> >> Rob
> >
> >
> >
------------------------------
Date: Mon, 06 Apr 1998 22:40:29 -0400
From: Ronald J Kimball <rjk@coos.dartmouth.edu>
Subject: Re: contexts: is there such a thing as array?
Message-Id: <3529921E.4FE40BBD@coos.dartmouth.edu>
Randal Schwartz wrote:
>
> >>>>> "M" == M J T Guy <mjtg@cus.cam.ac.uk> writes:
>
> M> Although you say "by definition" above, I can't actually find a
> M> definition of the behaviour in this case in the Perl documentation.
>
> I do. It's right in "man perldata", by example:
>
> @days{'a','c'} # same as ($days{'a'},$days{'c'})
>
> And "same as" seems to be fairly literal. It's intuitive that this
> comma there in a scalar context becomes the "evaluate left, discard,
> evaluate right" operator. And thus it works.
Nevertheless, MJT Guy was right in correcting that statement.
Here is the code sample he provided, slightly modified.
sub w { print wantarray ? "List\n" :
defined wantarray ? "Scalar\n" :
"Void\n";
shift;
}
@b = @a{w(1),w(2)};
@b = ($a{w(1)}, $a{w(2)});
$b = @a{w(1),w(2)};
$b = ($a{w(1)}, $a{w(2)});
And the result is:
List
List
Scalar
Scalar
List
List
Scalar
Scalar
Thus, @days{'a','c'} is *not* the same as ($days{'a'},$days{'c'}). The result
will be the same only if the expressions used as keys are independent of context.
--
_ / ' _ / - 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: Mon, 6 Apr 1998 15:59:21 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: "Frank D. Cringle" <fdc@cliwe.ping.de>
Subject: Re: Determining which flock strategy perl is using
Message-Id: <Pine.GSO.3.96.980406140435.22113F-100000@user2.teleport.com>
On Mon, 6 Apr 1998, Frank D. Cringle wrote:
> I am writing a small C program that creates/updates a Berkeley DB
> database. The database will then be accessible to Perl scripts using
> DB_File. Clearly the C program should use the same locking method
> as the local perl installation (flock/fcntl/lockf).
>
> Is it possible to extract the information from Config.pm?
Yes, no problem. To know how to interpret the values, just read the way
Perl uses the #defines in pp_sys.c, from the Perl source. Or, embed Perl
into your C program. :-) Hope this helps!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Mon, 6 Apr 1998 16:52:06 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: KHongLiu <khongliu@nease.net>
Subject: Re: easy way to enable perl script setuid?
Message-Id: <Pine.GSO.3.96.980406164044.22113J-100000@user2.teleport.com>
On Mon, 6 Apr 1998, KHongLiu wrote:
> Hi, please tell me some easy way to enable setuid perl script work,
> just as a setuid c program, thank you
The young couple from Cleveland are frantic. This is their first time
in New York City, they're lost, and they have tickets for a big
Broadway musical that starts in under ten minutes.
He runs into a restaurant and stops the first waiter he sees. "Quick,"
he cries, "What's the easiest way to get to Broadway?"
"Easy way? There's no easy way. You gotta practice, kid, practice."
Easy way to get set-id scripts to work? There's no easy way. You gotta
read perlsec, and maybe also the INSTALL file that comes with the perl
source.
(I'm not trying to be mean here. It wouldn't help you if I tried to teach
you how to load a gun before you learned basic gun safety, either.)
Cheers!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Mon, 6 Apr 1998 17:11:53 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Lloyd Zusman <ljz@asfast.com>
Subject: Re: How do I strip newlines from a var
Message-Id: <Pine.GSO.3.96.980406171102.22113L-100000@user2.teleport.com>
On 6 Apr 1998, Lloyd Zusman wrote:
> There's a polite way to point someone to the FAQ without answering his
> or her question in the newsgroup, and there is a rude way of doing so.
I've heard you say, "You catch more flies with honey..." about ten
different ways by now. :-)
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: 06 Apr 1998 20:23:58 -0400
From: Lloyd Zusman <ljz@asfast.com>
Subject: Re: How do I strip newlines from a var
Message-Id: <luemzazdgh.fsf@asfast.com>
Tom Phoenix <rootbeer@teleport.com> writes:
> On 6 Apr 1998, Lloyd Zusman wrote:
> > There's a polite way to point someone to the FAQ without answering his
> > or her question in the newsgroup, and there is a rude way of doing so.
>
> I've heard you say, "You catch more flies with honey..." about ten
> different ways by now. :-)
As Iave mentioned elsewhere, I'm trying to be creative. :)
And that's indeed my main point.
--
Lloyd Zusman
ljz@asfast.com
------------------------------
Date: Mon, 06 Apr 1998 19:12:11 -0500
From: mshavel@erols.com (Michael Shavel)
Subject: How to call a function every 15 seconds or so ?
Message-Id: <mshavel-0604981912110001@130.9.16.207>
HI
I have a perlscript that is used to call a dozen or so individual queries
on an Sybase database running on a UNIX box. The script is run through a
GUI made by perl/tk. I use the PID number of each process to determine if
the query is complete.
I am trying to create a sub routine in perl that will run a ps -ef |grep
$pidnum on the pidnum I get from running the process. I would like to
run the subroutine every 15 seconds or so to check and see if that
particular query is finished. I can write the subroutine fine but am at a
standstill when I try to figure out how I can call it every 15 seconds (or
any arbitrary time) to check and see if the process has ended. I don't
want to put the function call in a loop because I don't want to rest of
the program to lock up while I am waiting for this one process to end (I
have other queries I can run)
So my question is, am I missing something basic (some timer function or
something similar) or am I looking at something advanced (do I need to
make this script multi-threaded, if indeed this is even a possibility)
As always, thanks for any help and suggestions.
Mike Shavel
mshavel@erols.com
------------------------------
Date: 7 Apr 1998 01:52:51 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: How to call a function every 15 seconds or so ?
Message-Id: <6gc0tj$1ih$1@comdyn.comdyn.com.au>
In article <mshavel-0604981912110001@130.9.16.207>,
mshavel@erols.com (Michael Shavel) writes:
> So my question is, am I missing something basic (some timer function or
perldoc -f sleep
Martien
PS. In other words, look up the perl builtin function sleep().
--
Martien Verbruggen | My friend has a baby. I'm writing down
Webmaster www.tradingpost.com.au | all the noises the baby makes so later
Commercial Dynamics Pty. Ltd. | I can ask him what he meant - Steven
NSW, Australia | Wright
------------------------------
Date: Mon, 6 Apr 1998 19:13:43 -0400
From: "R. McCollum" <rmccollu@inet.net>
Subject: HTTP/1.0 200 OK : What's it mean???
Message-Id: <352962d1.0@news.inet.net>
Getting this when running SSI on IIS 3.0 ... Anybody know why?
Output look likes this...
The Guaranteed Rate for:
Life Products is HTTP/1.0 200 OK 5.00%
SSI line looks like this...calculates the 5.00% in the above line.
<!--#exec cgi="/css1/cgi-bin/getrate.pl" -->
Can anybody tell me how to get rid of the HTTP/1.0 200 OK in the middle of
the line??
R.McCollum
Provident Mutual
------------------------------
Date: Tue, 07 Apr 1998 01:28:45 GMT
From: jgloudon@manitoba.bbn.com (Jason Gloudon)
Subject: Re: HTTP/1.0 200 OK : What's it mean???
Message-Id: <slrn6ij05c.stm.jgloudon@manitoba.bbn.com>
R. McCollum <rmccollu@inet.net> wrote:
>Getting this when running SSI on IIS 3.0 ... Anybody know why?
>
>Output look likes this...
>
>The Guaranteed Rate for:
> Life Products is HTTP/1.0 200 OK 5.00%
>
>SSI line looks like this...calculates the 5.00% in the above line.
><!--#exec cgi="/css1/cgi-bin/getrate.pl" -->
This is not a perl question, even though your cgi is possibly written
in perl, please ask your question on the *cgi* related newsgroups.
--
Jason Gloudon
------------------------------
Date: Mon, 6 Apr 1998 16:57:06 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: gold_bag@yahoo.com
Subject: Re: I need latest perl for HPUX, AIX, Solaris
Message-Id: <Pine.GSO.3.96.980406165354.22113K-100000@user2.teleport.com>
On Mon, 6 Apr 1998 gold_bag@yahoo.com wrote:
> Where can i find compiled binaries of perl for HPUX, AIX, Solaris?
Right on your own machine, after you download and unpack the source and
use this command:
./Configure -ders && make && make test
At least, that always works for me. Hope this helps!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Mon, 6 Apr 1998 16:28:59 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Chocolate <poohba@io.com>
Subject: Re: If "=~" means match what is doesn't match?
Message-Id: <Pine.GSO.3.96.980406161922.22113G-100000@user2.teleport.com>
On Mon, 6 Apr 1998, Chocolate wrote:
> if($line =~ "Phone:") {
Almost always, you want to write that regular expression in slashes,
instead of quotes. Hope this helps!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: 7 Apr 1998 00:00:51 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: If "=~" means match what is doesn't match?
Message-Id: <6gbqbj$jf$1@comdyn.comdyn.com.au>
In article <Pine.BSI.3.96.980406073817.7640A-100000@pentagon.io.com>,
Chocolate <poohba@io.com> writes:
Please, read the perlop documentation, which explains all the
following, and much more. Documentation comes with perl, and can
generally be accessed with perldoc:
perldoc perlop
perldoc perl
perldoc perldoc
perldoc POSIX
You will learn a lot, if you spend some time in the documentation.
> if($line =~ "Phone:") {
This line leads me to believe that you're not looking for the =~
operator, which binds a scalar expression to a pattern match. It looks
like you want the 'eq' operator which does a stringwise comparison of
two scalars and returns a true value if they are equivalent.
=~ and !~ : bind a pattern match
if ($line =~ m|^[A-Z]+\d+$|)
if ($line !~ m|^[A-Z]+\d+$|)
eq and ne : stringwise comparison
if ($line eq 'Phone:')
if ($line ne 'Phone:')
== and != : numerical comparison
if ($a == 2)
if ($a != 2)
Martien
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au | Inside every anarchy lurks an old boy
Commercial Dynamics Pty. Ltd. | network - Mitchell Kapor
NSW, Australia |
------------------------------
Date: 7 Apr 1998 01:50:14 GMT
From: ehp@gte.net (Ethan H. Poole)
Subject: Re: If "=~" means match what is doesn't match?
Message-Id: <6gc0om$7qd$1@gte2.gte.net>
In article <Pine.BSI.3.96.980406073817.7640A-100000@pentagon.io.com>,
poohba@io.com says...
>
>But none of this works. How do I make it work? I want it to print a
>newline if the person doesn't have a phone number listed.
You're getting close. The opposite of =~ is !~
--
Ethan H. Poole | Website Design and Hosting,
| CGI Scripting...
========Personal========= | ============================
* ehp @ gte . net * | --Interact2Day--
http://home1.gte.net/ehp/ | http://www.interact2day.com/
------------------------------
Date: Mon, 06 Apr 1998 19:40:41 -0500
From: schinder@leprss.gsfc.nasa.gov (Paul J. Schinder)
Subject: Re: internationalisation of MacPerl
Message-Id: <schinder-0604981940420001@schinder.clark.net>
In article <hthetmeyer-0604981122240001@bonito.ifm.uni-kiel.de>,
hthetmeyer@ifm.uni-kiel.REMOVE.de (Helmut Thetmeyer) wrote:
} In article <alecler-0304981518270001@dialup-638.hip.cam.org>,
} alecler@cam.org (Andre L.) wrote:
}
} >use locale;
} >$s = "andri"; # e acute
} >print uc($s); # prints 'ANDRI' (E acute)
} >
} >This works fine in MacPerl 5.1.9r4, under System 7.5.5.
}
} Thank's a lot for this hint! It also works fine under MacOS 8.1. Where did
} you find this feature? It should be documented in macperl.pod - that would
} have saved me hours of searching.
It's probably not documented in macperl.pod because it's not a MacPerl
specific feature, but a feature of stock Perl. Fire up Shuck and from the
Go menu, Lookup locale. Look also in perldelta.pod.
}
} Best wishes, Helmut
}
} p.s. excuse me for considering to use something else than perl ;-)
}
--
Paul J. Schinder
NASA Goddard Space Flight Center
Code 693, Greenbelt, MD 20771
schinder@leprss.gsfc.nasa.gov
------------------------------
Date: Mon, 06 Apr 1998 22:48:38 -0400
From: Ronald J Kimball <rjk@coos.dartmouth.edu>
Subject: Re: Is there a "Newsgroup" for Newbies to Perl?
Message-Id: <35299407.90EED96E@coos.dartmouth.edu>
smitty77@pacbell.net wrote:
>
> In article <3525DF82.D5BB6DD4@coos.dartmouth.edu>, Ronald says...
> >
> >1) At work, you don't get 20 to 30 people coming up to you every single day to
> >ask the same questions over and over again.
>
> No one is coming up to YOU specifically.
Good point. In your analogy, the FAQer was only asking you. But in clpm, the
FAQer is bothering hundreds, if not thousands of people with their foolish question.
--
_ / ' _ / - 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: Mon, 06 Apr 1998 22:46:50 -0400
From: Ronald J Kimball <rjk@coos.dartmouth.edu>
Subject: Re: Is there a "Newsgroup" for Newbies to Perl?
Message-Id: <3529939B.65DCCBAC@coos.dartmouth.edu>
snitty77@pacbell, net wrote:
>
> In article <352868DC.A055D96C@coos.dartmouth.edu>, Ronald says...
> >
> >Because the message still takes up time and space being delivered. Because I
> >still have to wait for my newsreader to download the message. Because I still
> >have to read the message to find out if it is a worthwhile question.
> >
> >By the time I decide not to answer the question, it's already been a nuisance.
>
> What a pile of crap. You're reaching, Ronald. This is a public forum. And
> I'll repeat my question - I assume you're all for another newsgroup for these
> nuisances to go to, right?
How is that a pile of crap? Do you disagree that all of those assertions are true?
Yes, it's a public forum. What's your point? This public forum has
guidelines for posting, and those include not posting questions which are
clearly answered in the documentation.
Sure, if there were another newsgroup and all the silly FAQers went there
instead of posting here, that'd be great. But I don't think it would work,
for two reasons:
1) There would be nothing to stop the posters from cross-posting to both clpm
and the new newsgroup. As far as they are concerned, they get more attention
for their questions.
2) If all the FAQers went to that group, and all the experienced programmers
stayed in clpm, who would answer the questions in that group? The FAQers
would come to clpm looking to get their questions answered by the experts.
However, I will not stop you from creating the new group. I will even vote
YES.
--
_ / ' _ / - 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: 6 Apr 1998 23:40:12 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Need Reg Expr to yield today's cron jobs
Message-Id: <6gbp4s$af0$1@client3.news.psi.net>
James Vasile (vasile@hatespam.com) wrote on MDCLXXIX September MCMXCIII
in <URL: news:Pine.GSO.3.95qL.980406180818.24327A-100000@ciao.cc.columbia.edu>:
++ I am new to Perl and despite my lurking here for a week, combing through
++ scripts found on the web, and reading a borrowed copy of the Camel book, I
++ still cannot fit Regular Expressions into my head. My Perl code looks like
++ mangled BASIC and I'm thinking of just writing this silly little thing
++ in C. My problem is that I need a regular expression that will return the
++ lines in a crontab file that will be executed on a given date, usually
++ today's. The format of the data in crontab files is given in the manpage
++ for crontab(5). My Perl script has $month, $dayofweek and $dayofmonth set
++ to corresponding numbers. I just want to print today's cron entries...
++ should be easy, but it's not so for me.
It's easy. Just write the same regular expressions as you would do in C.
Of course, you might want to skip regular expressions and just use
split and localtime.
my ($mday, $mon, $wday) = (localtime) [3, 4, 6];
$mon ++;
open CRON, "/usr/spool/cron/foo" or
die "Failed to open /usr/spool/cron/foo: $!";
while (<CRON>) {
@chunks = split;
# Test day of the month;
unless ($chunks [2] eq '*') {
next unless grep {$mday == $_}
map {/(\d+)-(\d+)/ ? $1 .. $2 : $_}
split /,/, $chunks [2];
}
# Test month.
unless ($chunks [3] eq '*') {
next unless grep {$mon == $_}
map {/(\d+)-(\d+)/ ? $1 .. $2 : $_}
split /,/, $chunks [3];
}
# Test weekday.
unless ($chunks [4] eq '*') {
next unless grep {$wday == $_}
map {/(\d+)-(\d+)/ ? $1 .. $2 : $_}
split /,/, $chunks [4];
}
print;
}
Abigail
--
perl -MTime::JulianDay -lwe'$r=-2449231+gm_julian_day+time;@r=reverse(M=>(0)x99
=>CM=>(0)x399=>D=>(0)x99=>CD=>(0)x299=>C=>(0)x9=>XL=>(0)x39=>L=>(0)x9=>XL=>(0)x
29=>X=>IX=>0=>0=>0=>V=>IV=>0=>0=>I=>1);do{until($r<$#r){$_.=$r[$#r];$r-=$#r}for
(;!$r[--$#r];){}}while$r;$,="\x20";print+$_=>September=>MCMXCIII=>()'
------------------------------
Date: Mon, 06 Apr 1998 21:14:18 -0500
From: Eugene Sotirescu <eugene@vertical.net>
Subject: Re: Need Reg Expr to yield today's cron jobs
Message-Id: <35298BF8.E5D714E9@vertical.net>
Help us a little here: post an example of what your crontab line looks like
and even maybe the way you're trying to match what you need and why it's not
working. (If you're embarrased by your code, email me).
Eugene
James Vasile wrote:
> I am new to Perl and despite my lurking here for a week, combing through
> scripts found on the web, and reading a borrowed copy of the Camel book, I
> still cannot fit Regular Expressions into my head. My Perl code looks like
> mangled BASIC and I'm thinking of just writing this silly little thing
> in C. My problem is that I need a regular expression that will return the
> lines in a crontab file that will be executed on a given date, usually
> today's. The format of the data in crontab files is given in the manpage
> for crontab(5). My Perl script has $month, $dayofweek and $dayofmonth set
> to corresponding numbers. I just want to print today's cron entries...
> should be easy, but it's not so for me.
>
> Any help would be appreciated. No need to email me (I check this group
> often enough), but if you want to, please adjust my domain name to
> iname.com.
>
> Thanks in advance,
> -James
------------------------------
Date: Mon, 06 Apr 1998 22:46:38 GMT
From: jeff@yoak.com (Jeff Yoak)
Subject: Re: ORA Perl Conference Poll
Message-Id: <6gblul$4lv@dfw-ixnews2.ix.netcom.com>
[posted and emailed]
dustin@sonic.net (Dustin Mollo) wrote:
>Greetings fellow Perl enthusiasts!
>Some of you may know me as the www.perl.com maintainer. Others may not.
>Either way, I've been talking with ORA about maybe doing some live RealAudio
>broadcasts from this year's conference, and I was wondering how many here
>might be interested in something like that.
Dustin,
I'd be interested in that and would likely listen to as much of the
conference as was made available.
Cheers,
Jeff
--
Jeff Yoak jeff@yoak.com
------------------------------
Date: Mon, 06 Apr 1998 21:48:14 -0400
From: Stacy Hunter <snx@snx.com>
Subject: Password of the day
Message-Id: <352985D6.2304D861@snx.com>
I would like to have a password protected document where the password
automatically changes to meet given criteria each day.
Any recommendations?
I am also interested in obtaining a script for secure online ordering.
Thank you for your time.
Regards,
Stacy
------------------------------
Date: Tue, 07 Apr 1998 13:53:01 +1200
From: Jay and/or Blaise <jay.blaise@clear.net.nz>
Subject: perl login problem
Message-Id: <352986FD.18EDB0D2@clear.net.nz>
I am using a Perl script on a local computer via a MS Personal web
server.
I have associated the .pl file with perl and put it in the cgi bin.
When I try to run the script I get a PWS error saying that I am not
logged on to the server!
The PWS also seems to think that http://jay is the name of my server?
Does anybody with PWS knowledge/experience know whats gone awry?
Thanks in advance
Jay
--
Web Development: http://www.ipnz.com
Weblinks: http://www.ipnz.com/weblinks
Web Design:-:Web Hosting:-:Domain Registrations
--
Web Development: http://www.ipnz.com
Weblinks: http://www.ipnz.com/weblinks
Web Design:-:Web Hosting:-:Domain Registrations
------------------------------
Date: Mon, 6 Apr 1998 23:13:20 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: Seek and Read
Message-Id: <Er0Lu9.H4C@world.std.com>
Ted Gonzalez <sidney@acpub.duke.edu> writes:
>I don't understand these two functions very well. I need to know how I
>can use them to read a database text file in which each line has variable
>length and the fields in each line are delimited by a colon ":".
The function read() is almost never appropriate for variable length
records. It reads the specified number of bytes from the file and has
no idea where the underlying fields or records are located.
seek() is not very useful in variable length files. You can only tell
it to move the file pointer a certain number of bytes. The only
exception to this is seek()ing back to the beginning of the file to
read it over again.
The only other way that I can think of that seek() would be useful is
if you read through the files multiple times, and the first time you
use tell() before reading the line to find the offset for that line.
If the files are too large to put in memory all at once, and
performace is not important, this might be the way to go.
#!/usr/bin/perl -w
use IO::File;
my @pos;
my $file = shift @ARGV;
open FILE, "< $file" or die "Can't open $file: $!\n";
push @pos, 0;
while(<FILE>) {
push @pos, tell FILE;
}
for my $linenumber (@ARGV) {
die "invalid line number: $linenumber\n" if $linenumber =~ /\D/;
seek FILE,$pos[$linenumber], SEEK_SET;
print scalar <FILE>;
}
If the file isn't too big, you might be best off loading it into
memory all at once.
#!/usr/bin/perl -w
my $file = shift @ARGV;
open FILE, "< $file" or die "Can't open $file: $!\n";
my @lines = <FILE>;
for $linenumber (@ARGV) {
die "invalid line number: $linenumber\n" if $linenumber =~ /\D/;
print $lines[$linenumber];
}
If the file is too big to keep in memory, and performance is
important, then you might want to convert the file into a more
convenient format (Either a DBM file or a fixed length file) when you
install the file, and then use the higher performance format for use.
--
Andrew Langmead
------------------------------
Date: Mon, 6 Apr 1998 20:47:36 -0400
From: Ted Gonzalez <sidney@acpub.duke.edu>
Subject: Re: Seek and Read
Message-Id: <Pine.SOL.3.91.980406204435.3943A-100000@godzilla6.acpub.duke.edu>
On Mon, 6 Apr 1998, Andrew M. Langmead wrote:
> If the file is too big to keep in memory, and performance is
> important, then you might want to convert the file into a more
> convenient format (Either a DBM file or a fixed length file) when you
> install the file, and then use the higher performance format for use.
How would I do that?
Ted
------------------------------
Date: Tue, 7 Apr 1998 02:39:41 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: Seek and Read
Message-Id: <Er0vE5.I6r@world.std.com>
Ted Gonzalez <sidney@acpub.duke.edu> writes:
>On Mon, 6 Apr 1998, Andrew M. Langmead wrote:
>> If the file is too big to keep in memory, and performance is
>> important, then you might want to convert the file into a more
>> convenient format (Either a DBM file or a fixed length file) when you
>> install the file, and then use the higher performance format for use.
>How would I do that?
For DBM file, lets say you have a file with colon separated
records. You want to use this file to make a DBM file in which you
pass the first field, and it will quickly return the record.
#!/usr/bin/perl -w
use NDBM_File;
use Fcntl;
# no, I'n not going to let the name the file "0"
$infile = shift @ARGV || die 'No input file specified';
$outfile = shift @ARGV || die 'No output file specified';
# open text file for reading.
open TEXT, $infile or die "Can't open $infile: $!\n";
# open DBM file, and make it seem like a hash.
tie %db, 'NDBM_File', $outfile, O_RDWR|O_CREAT, 0640
or die "Error tieing to database\n";
# loop through the text file.
while(<TEXT>) {
chomp;
# extract the key field from the record
($key) = split /:/, $_, 2;
# store in the DBM file
$db{$key} = $_;
}
__END__
And probably to be on the safe side, you will probably want to create
another program that reads the DBM file, and writes out the
correspoding text file.
#!/usr/bin/perl -w
use NDBM_File;
use Fcntl;
$infile = shift @ARGV || die 'No input file specified';
$outfile = shift @ARGV || die 'No output file specified';
# open text file for writing.
open TEXT, ">$outfile" or die "Can't open $infile: $!\n";
# open DBM file, and make it seem like a hash.
tie %db, 'NDBM_File', $infile, O_RDONLY|O_CREAT, 0640
or die "Error tieing to database\n";
# loop through the DBM file.
while(($key, $value) = each %db) {
# print the data.
print TEXT "$value\n";
}
__END__
But for the regular work, you use the DBM file rather than the text
file.
#!/usr/bin/perl -w
use NDBM_File;
use Fcntl;
my $dbfile = shift @ARGV || die "Must specify DBM file";
my $replace = shift @ARGV;
die "must specify record" unless defined $replace; # key may be "0"
my($key) = split /:/, $replace, 2;
tie %db, 'NDBM_File', $dbfile, O_RDWR, 0640
or die "Error tieing to database\n";
# perform a lookup
if(defined $db{$key}) {
print "replacing: $db{$key}\n";
}
else {
print "new reccord\n";
}
# perform an insertion
$db{$key} = $replace;
__END__
For fixed length files, lets say you know that no record (including
the field separators) is going to be longer than 100 bytes. And lets
say you want to be able to quickly jump to a record by record
number. You could make scripts similar to the DBM scripts that load
and dump the database. (You may want to use pack() with the "A" format
to make the fixed length records)
Then to jump to a particular record, you multiply the record number by
the length of the record, use seek() (as I showed in the last post.)
to move the file pointer to the beginning of the record, and read.
One other option, would be to keep the colon separated file alone, and
make a seprate fixed length file that contains the offsets of each
line. Instead of the "load" and "dump" scripts like the DBM example,
you just need one "index" script that would take the text file and
output the offsets. (Again, the last post showed how to use tell() to
determine the current postion in the file.) Maybe you could even
arrange things so that you determine if the text database is newer
than the index, and update the index automatically.
Then you would open up the index file, seek to the record number, read
the offset from that position, open up the text file, seek to that
offset, and read the record.
I'm sorry I'm getting increasingly vague as I go on in this
article. Its just that:
1. I'm getting bored with the subject.
2. Its getting late, and I've spent more than my average time on this.
3. I'm getting increasingly suspicious that I'm doing someones
homework for them.
--
Andrew Langmead
------------------------------
Date: Tue, 07 Apr 1998 02:56:17 +0200
From: Web-Hotel Danmark <support@webhot.dk>
Subject: Socket problems!
Message-Id: <352979B0.FCD648DB@webhot.dk>
Hi,
I've tried for several days now to get e script to call a HTTP-server by
using a socket-connection, but no matter what site I try to call, the
only result I get is the default-page from the HTTP-server running om
the same machine I execute the script on...
What do I do now ?
The server is Running Apache, Perl5 on SunOS (SPARC 2)
-Palle Nielsen
------------------------------
Date: Mon, 6 Apr 1998 23:52:02 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: using modules
Message-Id: <Er0nMq.HED@world.std.com>
amehdiza@joule.ee.calpoly.edu (Ali Mehdizadeh) writes:
>I am trying to use the ceil() function which is apparently
>part of the posix module. I have tried the following without
>any luck:
>ceil($num);
>posix::ceil($num);
>I am using perl under NT. What am I doing wrong?
Its a couple of different things going on at the same time. Once you
fix these, either of the two lines should work.
1. You also need a "use POSIX;" line to import the POSIX module.
2. Perl identifiers are case sensitive, you have to refer to the POSIX
module as "POSIX", not "posix".
3. Windows NT is not an POSIX complient system (except for a
perversely comical POSIX mode that has no access to the any Win32
functions. Including all of the graphics functions.) so it does not
have a POSIX module.
--
Andrew Langmead
------------------------------
Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 8 Mar 97)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.
The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V8 Issue 2262
**************************************