[18831] in Perl-Users-Digest
Perl-Users Digest, Issue: 999 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun May 27 18:05:31 2001
Date: Sun, 27 May 2001 15:05:09 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <991001109-v10-i999@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Sun, 27 May 2001 Volume: 10 Number: 999
Today's topics:
Re: ? The best Perl book ? (Chris)
Re: ? The best Perl book ? (Tad McClellan)
Re: Cannot traverse my own structure... <bart.lateur@skynet.be>
Re: Clarification and question about FAQ <newspost@coppit.org>
Re: Clarification and question about FAQ <dxb@DONOTSPAM.com>
Re: Clarification and question about FAQ (Tad McClellan)
Re: Clarification and question about FAQ <buggs@geekmail.de>
convert letters to numbers <mail@NOSPAMericmarques.net>
Re: convert letters to numbers (Tad McClellan)
Re: convert letters to numbers <mail@NOSPAMericmarques.net>
Re: convert letters to numbers <godzilla@stomp.stomp.tokyo>
Re: convert letters to numbers <bart.lateur@skynet.be>
Re: convert letters to numbers (Michael Fuhr)
Curses and Macperl <penfold@deadbeat.edu>
Fcntl usage with tie? <m.grimshaw@salford.ac.uk>
Fcntl usage? <m.grimshaw@salford.ac.uk>
How to match and print like this ??? <cadmcse@hotmail.com>
Is there such as thing as an array of structures in Per <chris_newman@bigpond.com>
Locking files <shino_korah@yahoo.com>
Nested If <bwilmot@jumpnow.net>
Re: Nested If (Jay Tilton)
Re: Nested If <godzilla@stomp.stomp.tokyo>
Re: perl cookies <mail@NOSPAMericmarques.net>
Re: perl history (*?) <bart.lateur@skynet.be>
Re: perl history (*?) (Tad McClellan)
Re: Question <bart.lateur@skynet.be>
Re: Question <godzilla@stomp.stomp.tokyo>
Re: tail -f in a perl-program (Konstantinos Agouros)
Re: Time validation <daryl.shute@pss.boeing.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 27 May 2001 13:08:51 -0700
From: chrisl_ak@hotmail.com (Chris)
Subject: Re: ? The best Perl book ?
Message-Id: <b62b39cb.0105271208.49923b0e@posting.google.com>
I HIGHLY recommend _Beginning Perl Programming_ by Simon Cozens from
Wrox press. I have it and _Learning Perl_ as beginner books. _LP_ is
cool and always recommended, but the Wrox book really-- ahem-- rocks.
Head and shoulders above the rest.
Then _Programming Perl_ (O'Reilly) and the _Effective Perl
Programming_ book whose author escapes me.
I can't wait for the Professional Perl book from Wrox.
------------------------------
Date: Sun, 27 May 2001 16:05:56 -0400
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: ? The best Perl book ?
Message-Id: <slrn9h2nh4.915.tadmc@tadmc26.august.net>
Chris <chrisl_ak@hotmail.com> wrote:
>
>the _Effective Perl
>Programming_ book whose author escapes me.
^^^^^^
Joseph Hall
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sun, 27 May 2001 19:36:42 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Cannot traverse my own structure...
Message-Id: <esl2ht4v1tbca3r835h3p4tnhmffrs8iq5@4ax.com>
Robert Nicholson wrote:
>I'm building what I believe to be a structure that looks like this
>
>{ cinemaName, ( { movieTitle, (show times) }, { movieTitle, (show times) } ) }
You can always use Data::Dumper and see what it really looks like.
--
Bart.
------------------------------
Date: Sun, 27 May 2001 14:02:14 -0400
From: David Coppit <newspost@coppit.org>
Subject: Re: Clarification and question about FAQ
Message-Id: <Pine.SUN.4.33.0105271344030.29478-100000@mamba.cs.Virginia.EDU>
On Sun, 27 May 2001, David Ball wrote:
> First a bit of history. I started by asking a simple perl question. Someone
> made a suggestion of doing it a different way and I thanked them and asked
> them if they knew of any programs that did that withen my response. For
> some reason I was attacked as posting off-topic. I saw no justification for
> the attack, and I still don't understand why it would merit one.
First, don't confuse a few people who make their point with a
sledgehammer for the policy of the newsgroup. Most of the offtopic
reminders I see are fairly polite, but to the point.
Second, it takes two to maintain a flame war. A quick review of a
couple posts by you show several whose only content is "Why are you
such a jerk", or "You are such a jerk". In contrast, I rarely see
people like Abigail and Anno post something without a (usually gold)
nugget of content. [My apologies to you if my search did not yield a
representative sample of your posts.]
Third, as explained to you, your question was about scripts to do a
particular web task, not about the Perl language. If you can
characterized your question in terms of Perl, maybe you'd get a better
response. (e.g. "How can I implement this indexing algorithm in
Perl?", "Is this a good way to use the CGI module to handle a search
query?", etc.)
> Could someone point me towards the updated FAQ. I usually try to follow the
> guidelines for a group, but when I'm attacked for what I see as a
> reasonable post, I tend to respond in kind.
I think the rec.* comment isn't quite accurate, but others can
disagree. There's an ongoing effort to provide a set of posting
guidelines, and it covers, among other things, exactly the sort of
question you asked.
--
Regards,
David
------------------------------
Date: Sun, 27 May 2001 13:26:44 -0700
From: db <dxb@DONOTSPAM.com>
Subject: Re: Clarification and question about FAQ
Message-Id: <jun2htsdda9i7am3ekmj6mi37ijp28bhv4@4ax.com>
Thanks you for your comments, David.
Very few newsgroups seem to have as strict a policy as this one about
posting. I really wish they would get the FAQ updated and spread around the
net so that people don't think it's the friendly community sort of place
that the old FAQ describes.
It's obviously NOT a group I'm comfortable with, and I rarely use perl so I
probably won't post here again, but I would like to see some sort of
warning posted regularly so others who are new to the group will realize
what kind of policy is in place. I've been on usenet since the early 90's
and, in all the groups I've visited, I've never encountered such a strict
group. It's not what most people will be expecting when they first visit
here.
GoodBye and Best Wishes,
David
------------------------------
Date: Sun, 27 May 2001 14:32:09 -0400
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Clarification and question about FAQ
Message-Id: <slrn9h2i19.8u1.tadmc@tadmc26.august.net>
David Ball <db9@NOSPAM.com> wrote:
>
>asked
>them if they knew of any programs that did that withen my response.
And that question was answered.
>For
>some reason I was attacked as posting off-topic. I saw no justification for
>the attack, and I still don't understand why it would merit one.
We help with _writing_ Perl programs here. Use a search engine
for searching for ready-made Perl programs.
>Has a new faq been written for the group.
No, but there has been a supplementary one written.
You even followed up to a thread rooted from those Posting Guidelines.
They are still being revised and discussed here.
>I don't see why I should have been flamed for thanking
>someone and asking them if they knew of a program that does things the way
>they suggested.
You were probably perceived (rightly or wrongly) as asking for
someone else to do your work for you.
We will help you write Perl programs. We will not help you locate
Perl programs.
>Could someone point me towards the updated FAQ.
http://dfw.pm.org/clpmisc.shtml
>I tend to respond in kind.
That is unfortunate, as you have no doubt landed in many killfiles
as a result of it. Changing posting addresses won't help, I just
added that one too. :-(
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sun, 27 May 2001 23:56:57 +0200
From: buggs <buggs@geekmail.de>
Subject: Re: Clarification and question about FAQ
Message-Id: <9ert5j$8nf$03$1@news.t-online.com>
db wrote:
--snip--
> It's obviously NOT a group I'm comfortable with, and I rarely use perl so
> I probably won't post here again, but I would like to see some sort of
> warning posted regularly so others who are new to the group will realize
> what kind of policy is in place. I've been on usenet since the early 90's
> and, in all the groups I've visited, I've never encountered such a strict
> group. It's not what most people will be expecting when they first visit
> here.
You got flamed.
After ten years of usenet
your ego still can't deal with it.
You flame back in a far heftier way
without checking whom you flame.
One wonders what kind of NewsAdmin you are, fetchnews ?
>
> GoodBye and Best Wishes,
>
> David
And then go away without learning.
What a pity :-(
Buggs
------------------------------
Date: Sun, 27 May 2001 20:44:19 GMT
From: "Eric" <mail@NOSPAMericmarques.net>
Subject: convert letters to numbers
Message-Id: <DGdQ6.34992$PF4.70354@news.iol.ie>
how do i convert a string of text (username) like "Eric Marques" to a number
converting back doesnt matter i dont need it
--
Eric Marques
mail@ericmarques.net
------------------------------
Date: Sun, 27 May 2001 16:10:46 -0400
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: convert letters to numbers
Message-Id: <slrn9h2nq6.920.tadmc@tadmc26.august.net>
Eric <mail@NOSPAMericmarques.net> wrote:
>how do i convert a string of text (username) like "Eric Marques" to a number
>converting back doesnt matter i dont need it
sub convert2number {
return 1;
}
print convert2number("Eric Marques"), "\n";
A poor specification is likely to result in an unsatisfactory implementation.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sun, 27 May 2001 21:10:04 GMT
From: "Eric" <mail@NOSPAMericmarques.net>
Subject: Re: convert letters to numbers
Message-Id: <M2eQ6.35002$PF4.70439@news.iol.ie>
hmm..
whats the point of that
it always returns a 1 even if i change the text :(
--
Eric Marques
mail@ericmarques.net
"Tad McClellan" <tadmc@augustmail.com> wrote in message
news:slrn9h2nq6.920.tadmc@tadmc26.august.net...
> Eric <mail@NOSPAMericmarques.net> wrote:
> >how do i convert a string of text (username) like "Eric Marques" to a
number
> >converting back doesnt matter i dont need it
>
>
> sub convert2number {
> return 1;
> }
>
> print convert2number("Eric Marques"), "\n";
>
>
> A poor specification is likely to result in an unsatisfactory
implementation.
>
>
> --
> Tad McClellan SGML consulting
> tadmc@augustmail.com Perl programming
> Fort Worth, Texas
------------------------------
Date: Sun, 27 May 2001 14:24:45 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: convert letters to numbers
Message-Id: <3B11709D.AECF8AA6@stomp.stomp.tokyo>
Eric wrote:
> how do i convert a string of text (username) like "Eric Marques" to a number
> converting back doesnt matter i dont need it
Open a dictionary and familiarize yourself
with our word, parameter, then think of this
word in a plural context and its relationship
to programming.
$name = time();
Godzilla!
------------------------------
Date: Sun, 27 May 2001 21:42:59 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: convert letters to numbers
Message-Id: <e8t2ht041d2765eesgghcoe3r5473l5lv5@4ax.com>
Eric wrote:
>how do i convert a string of text (username) like "Eric Marques" to a number
>converting back doesnt matter i dont need it
What number?
if($username eq 'Eric Marques') {
return 42;
}
I don't think this is what you want.
--
Bart.
------------------------------
Date: 27 May 2001 15:49:08 -0600
From: mfuhr@dimensional.com (Michael Fuhr)
Subject: Re: convert letters to numbers
Message-Id: <9ersok$2vu@flatland.dimensional.com>
"Eric" <mail@NOSPAMericmarques.net> writes:
> hmm..
> whats the point of that
> it always returns a 1 even if i change the text :(
You missed the point: your requirements weren't specific enough.
Tad's not a mind-reader (at least I don't think he is), so he wrote
a subroutine that does exactly what you asked. No more, no less.
Welcome to the world of software development.
I'm sure you had something else in mind, but we don't know what
that is unless you tell us.
> "Tad McClellan" <tadmc@augustmail.com> wrote in message
> news:slrn9h2nq6.920.tadmc@tadmc26.august.net...
> > Eric <mail@NOSPAMericmarques.net> wrote:
> > >how do i convert a string of text (username) like "Eric Marques" to a
> number
> > >converting back doesnt matter i dont need it
> >
> >
> > sub convert2number {
> > return 1;
> > }
> >
> > print convert2number("Eric Marques"), "\n";
> >
> >
> > A poor specification is likely to result in an unsatisfactory
> > implementation.
--
Michael Fuhr
http://www.fuhr.org/~mfuhr/
------------------------------
Date: Sun, 27 May 2001 15:36:52 -0500
From: Eric Inazaki <penfold@deadbeat.edu>
Subject: Curses and Macperl
Message-Id: <270520011536525474%penfold@deadbeat.edu>
Hi,
Is there a curses package for macperl? I'm using various versions of
perl5 on macs, suns and an old and decrepit sgi (oh, and windows too)
and I'm looking to do text based UI things that can run on all these
platforms. (I think the only hangup is with the mac).
Thanks in advance,
eric
------------------------------
Date: Sun, 27 May 2001 15:56:21 +0100
From: Mark Grimshaw <m.grimshaw@salford.ac.uk>
Subject: Fcntl usage with tie?
Message-Id: <3B111595.291F969B@salford.ac.uk>
Hi,
I'm getting the following warning when tieing a DB_File with O_RDONLY:
Argument "O_RDONLY" isn't numeric in entersub at
/usr/local/lib/perl5/5.00502/IP22-irix/DB_File.pm line 255 (#1)
(W) The indicated string was fed as an argument to an operator that
expected a numeric value instead. If you're fortunate the message
will identify which operator was so unfortunate.
The DB file is opened and the program works. However, I'd like to get
rid of this warning message. Any ideas what I'm doing wrong?
------------------------------
Date: Sun, 27 May 2001 14:17:13 +0100
From: Mark Grimshaw <m.grimshaw@salford.ac.uk>
Subject: Fcntl usage?
Message-Id: <3B10FE59.C56EDC0A@salford.ac.uk>
Hi,
Trying to use Fcntl; with O_RDONLY, OCREAT etc. for tie operations with
Berkeley DB on 5.005_02 built for IP22-irix.
Everything works fine but when I use strict; I get warnings (still
works). The warning is:
Argument "O_RDONLY" isn't numeric in entersub at
/usr/local/lib/perl5/5.00502/IP22-irix/DB_File.pm line 255 (#1)
(W) The indicated string was fed as an argument to an operator that
expected a numeric value instead. If you're fortunate the message
will identify which operator was so unfortunate.
I could use explicit values for the constants but would like to keep the
code portable.
Any ideas how to get rid of the warning?
------------------------------
Date: Sun, 27 May 2001 20:21:23 GMT
From: "cad" <cadmcse@hotmail.com>
Subject: How to match and print like this ???
Message-Id: <7ldQ6.44689$ko.579910@news1.frmt1.sfba.home.com>
can anyone help me this Perl problem,... this is a very difficult for
me..
I have a text file like this:
MN109 ADDPAD hn
MN207 n1 ADDPAD hn
MN208 n1 CEB hn
MN209 n1 hn
MP202 ADDPAD NP1 hp
MP204 ADDPAD NP1 hp
MP206 NP1 hp
MP216 net145 ADD n1 hp
MP205 NP1 CEB n1 hp
XI119 ADD n1 inv
MP234 NP1 CEB net145 hp
every line first element is "master", last element is "instance"
elements between first and last are all netnames,
I have already grep to @master, @netnames #netname already erase duplicate
and I need do match and print report like this
MN109 MN207 MN208 .... XI119 MP234 #(master)
#(netname)
ADD X
n1 X X X
ADDPAD X X
NP1
X
....
which means I need to print&check netname line by line
to check if it mach each text line above if it mach the "master" , print "X"
can any expert hep me the solve the problem?
I really don't know how to write a loop or algorithm to do this ><
------------------------------
Date: Mon, 28 May 2001 06:55:17 +1000
From: Chris Newman <chris_newman@bigpond.com>
Subject: Is there such as thing as an array of structures in Perl?
Message-Id: <B737A6D5.6A38%chris_newman@bigpond.com>
I come from using C++ where I use these regularly but have not seen a
mention of these in any of the books I have read for example Learning Perl.
Perl 5 by example
------------------------------
Date: Sun, 27 May 2001 12:22:14 -0700
From: "terminalsplash" <shino_korah@yahoo.com>
Subject: Locking files
Message-Id: <9erk57$4vu@news.or.intel.com>
I have a program writing to a file A.txt.
I have to process this file,so I lock the A.txt and then copy it to another
file B.txt and release the lock
This is my code
open(FD, "A.txt") or die "can't open ::$!\n";
flock(FD,LOCK_SH) or die "can't lock :;$!\n";
if(!copy("A.txt","B.txt")){
print "Error in copying :: $!\n";
}
close (FD);
But sometimes I get an error saying
Error in copying :: Stale NFS file handle
Why am I getting this error when I'm locking this file?
Thanks in advance
------------------------------
Date: Sun, 27 May 2001 14:02:35 -0700
From: "Brian Wilmot" <bwilmot@jumpnow.net>
Subject: Nested If
Message-Id: <9erq9u$q71a$1@ID-44450.news.dfncis.de>
Ok...I might just be an idiot but what is wrong with the expression
If ($username eq "")
{
print "Please press your browser's back button and enter a business
name.\n";
exit;
}
This is nested within another If block. I though you could nest If
statements in PERL(Am I wrong)
I keep gettign an error "Syntax error near "exit" on line xx" I'm dying
here. It's checking to see if the var is empty and if it is it exits with
the message.
--
Brian Wilmot
http://www.jumpnow.net/
http://www.uglybillboards.com/
"You can die but you're never dead" - Red Hot Chili Peppers
------------------------------
Date: Sun, 27 May 2001 21:23:18 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: Nested If
Message-Id: <3b11701f.1685299@news.erols.com>
On Sun, 27 May 2001 14:02:35 -0700, "Brian Wilmot"
<bwilmot@jumpnow.net> wrote:
>Ok...I might just be an idiot but what is wrong with the expression
>
>If ($username eq "")
^^
^^
Case matters.
------------------------------
Date: Sun, 27 May 2001 14:35:32 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Nested If
Message-Id: <3B117324.96748C1E@stomp.stomp.tokyo>
Brian Wilmot wrote:
> Ok...I might just be an idiot but what is wrong with the expression
> If ($username eq "")
> {
> print "Please press your browser's back button and enter a business
> name.\n";
> exit;
> }
Use a lowercase "if" for this.
if ($username .. etc
Godzilla!
------------------------------
Date: Sun, 27 May 2001 20:55:15 GMT
From: "Eric" <mail@NOSPAMericmarques.net>
Subject: Re: perl cookies
Message-Id: <TQdQ6.34999$PF4.70371@news.iol.ie>
hmm...
on the second script try
#!/usr/bin/perl
print "Content-Type: text/html\n\n";
print "$ENV{'HTTP_COOKIE'}";
--
Eric Marques
mail@ericmarques.net
"Hans" <h.born@fh-aargau.ch> wrote in message
news:8d27eb70.0105261326.37f4647a@posting.google.com...
> Hi there,
>
> I definetly need a hand with perl and cookies.
> I wrote two very small skripts but wasn't retrieving the cookie back.
> Skript one sets a cookie (this works just fine, I also checked the
cookies.txt
> on the client and the entry is there, this shows me the cookie has
been placed).
> But retrieving the cookie back, with skript two, doesn't work, the
value is always
> empty.
>
> What am I doing wrong? Can somebody please help me out? I appreciate
it!
>
>
> skript one (set the cookie):
>
> #!/usr/bin/perl
> # cookie1
>
> use strict;
> use CGI qw/:standard/;
> use CGI::Cookie;
>
>
> my $CGIquery = CGI::new();
>
> my $id = "7";
> my $exp='+1d';
> my $your_cookie = new CGI::Cookie(
> -name=>'dva',
> -value=>"6676",
> -expires=>$exp
>
> );
>
> print $CGIquery->header(-cookie=>$your_cookie);
>
> print "cookie set";
>
> $CGIquery->end_html();
>
> skript two (retrieve the cookie):
>
> #!/usr/bin/perl
> # cookie2
>
> use strict;
> use CGI qw/:standard/;
> use CGI::Cookie;
>
>
> my $CGIquery = CGI::new();
>
> my $retreived_cookie = cookie('dva');
>
> print $CGIquery->header();
>
> print "cookie content: $retreived_cookie";
>
> $CGIquery->end_html();
------------------------------
Date: Sun, 27 May 2001 19:34:50 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: perl history (*?)
Message-Id: <kkl2ht8tfq3fddq8j3o28unflg4dbqtiev@4ax.com>
Charles Blair wrote:
> Has anyone compiled a list of when the most important
>extensions were made to perl, both in terms of version and
>calendar time?
>
> For example, I have written something that uses the *?
>capability for regular expressions. I'm pretty sure this
>was not in 4.036, which (I think) means that a lot of people
>with five-year-old installations won't be able to run it.
Every perl distribution includes a file called "perldelta"; which lists
the relevant changes since the latest major minor update. (?!? I mean,
for example, from 5.004 to 5.005.)
If you have the perldeltas for all the important upgrades, it ought to
be possible to search these files for the info you're looking for.
I think the *? AKA non-greedy matching was added in 5.005.
--
Bart.
------------------------------
Date: Sun, 27 May 2001 14:47:44 -0400
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: perl history (*?)
Message-Id: <slrn9h2iug.8u1.tadmc@tadmc26.august.net>
Charles Blair <c-blair@uiuc.edu> wrote:
>in 4.036, which (I think) means that a lot of people
>with five-year-old installations won't be able to run it.
That is a good thing, as people running five-year-old perls
have security holes that have been fixed in modern perls.
If they continue with software that has CERT advisories against
it, your program not working is small potatoes compared to having
their site cracked. We'll see them on the 6 o'clock news...
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sun, 27 May 2001 19:29:40 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Question
Message-Id: <h7l2htgdjnpjqmc51c0lltrlfk2bqqs99p@4ax.com>
scott.bell1 wrote:
>I'm trying to write a webpage in CGI that will remember the most recent
>visitors to my page and will display them to anyone who visits the "who's
>watching" page, all I'm interested in now is storing the last 10 IP
>addresses. Can anyone help me with this?
<http://www.stonehenge.com/merlyn/WebTechniques/col04.html>
--
Bart.
------------------------------
Date: Sun, 27 May 2001 13:34:49 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Question
Message-Id: <3B1164E9.9C7234C3@stomp.stomp.tokyo>
scott.bell1 wrote:
> I'm trying to write a webpage in CGI that will remember the most recent
> visitors to my page and will display them to anyone who visits the "who's
> watching" page, all I'm interested in now is storing the last 10 IP
> addresses. Can anyone help me with this?
You need to fix your email address for readily apparent reasons.
There are some givens for my test script found beneath my
signature. This script needs to be initialized with ten
IP Addresses before it will display just that; ten addresses.
Including variable declarations, error checking and the such,
is up to you. Some minor modifications are needed to ready
this script for internet use. An obvious given is you will
need to incorporate this per your needs and script, should
you elected to use a method similar to what I display.
$ENV{REMOTE_ADDR} = "Sample.IP";
This line needs to be removed for internet usage.
I have set this environmental variable for local
machine testing; no remote address is available.
My ipdata.txt is initialized as an empty file.
Create this file and load it to your server.
Be sure to include a full internal path to
this file for your script. An example:
open (IP_DATA, "/var/scott/public_html/logs/ipdata.txt");
Same is true for the write open:
open (IP_DATA, ">/var/scott/public_html/logs/ipdata.txt");
If you expect a lot of hits, high traffic, locking this
file would be suggested but is for you to decide.
Find these seven lines:
if ($#IP_Data < 9)
{ push (@IP_Data, "$date - $ENV{'REMOTE_ADDR'}<BR>\n") }
else
{
shift (@IP_Data);
push (@IP_Data, "$date - $ENV{'REMOTE_ADDR'}<BR>\n")
}
Those seven lines are used to initialize my script with
ten entries into array IP_Data. Once you have ten entries
within your database file, my ipdata.txt file, this can be
modified to these two lines only:
shift (@IP_Data);
push (@IP_Data, "$date - $ENV{'REMOTE_ADDR'}<BR>\n")
Use of shift will remove the oldest entry and, use of
push will add the most recent entry. Be sure you have
ten entries in your database before changing those
lines, your display will be incorrect otherwise.
# @IP_Data = reverse (@IP_Data);
Uncomment this line above if you want descending
order for your print.
print @IP_Data;
You may add your html tags as needed to above line
or simply set a variable for later use, whatever.
Do note I have already added <BR> for each array
element to shortcut your html tag needs. My use
of an added \n character is to present a neat
and crisp document source print and, so this
file can be slurped to create an array.
Null entries into my array IP_Data should not be
a problem. A time stamp and IP address _should_
always be available. However, a crash of sorts
might generate a null entry. You might consider
error checking on this although a rare event.
Even more rare, would be a complete loss of your
database file; non-existent. Error checking
could be added for this. In short, plan ahead
for all _reasonable_ possibilities.
As to $date, you can modify this to print anything
you want using typical timestamp formatting.
Godzilla!
--
#!perl
$ENV{REMOTE_ADDR} = "Sample.IP";
open (IP_DATA, "ipdata.txt");
@IP_Data = <IP_DATA>;
close (IP_DATA);
$date = localtime();
if ($#IP_Data < 9)
{ push (@IP_Data, "$date - $ENV{'REMOTE_ADDR'}<BR>\n") }
else
{
shift (@IP_Data);
push (@IP_Data, "$date - $ENV{'REMOTE_ADDR'}<BR>\n")
}
open (IP_DATA, ">ipdata.txt");
print IP_DATA @IP_Data;
close (IP_DATA);
# @IP_Data = reverse (@IP_Data);
print @IP_Data;
exit;
PRINTED RESULTS - FIRST TEN RUNS:
_________________________________
Sun May 27 12:13:05 2001 - Sample.IP<BR>
Sun May 27 12:13:12 2001 - Sample.IP<BR>
Sun May 27 12:13:38 2001 - Sample.IP<BR>
Sun May 27 12:13:41 2001 - Sample.IP<BR>
Sun May 27 12:13:45 2001 - Sample.IP<BR>
Sun May 27 12:13:50 2001 - Sample.IP<BR>
Sun May 27 12:13:55 2001 - Sample.IP<BR>
Sun May 27 12:14:06 2001 - Sample.IP<BR>
Sun May 27 12:14:11 2001 - Sample.IP<BR>
Sun May 27 12:14:18 2001 - Sample.IP<BR>
PRINTED RESULTS - ELEVEN RUNS:
______________________________
Sun May 27 12:13:12 2001 - Sample.IP<BR>
Sun May 27 12:13:38 2001 - Sample.IP<BR>
Sun May 27 12:13:41 2001 - Sample.IP<BR>
Sun May 27 12:13:45 2001 - Sample.IP<BR>
Sun May 27 12:13:50 2001 - Sample.IP<BR>
Sun May 27 12:13:55 2001 - Sample.IP<BR>
Sun May 27 12:14:06 2001 - Sample.IP<BR>
Sun May 27 12:14:11 2001 - Sample.IP<BR>
Sun May 27 12:14:18 2001 - Sample.IP<BR>
Sun May 27 12:14:33 2001 - Sample.IP<BR>
------------------------------
Date: 27 May 2001 21:20:21 +0200
From: elwood@news.agouros.de (Konstantinos Agouros)
Subject: Re: tail -f in a perl-program
Message-Id: <elwood.990991152@news.agouros.de>
In <9eq0m2$7eu$1@sloth.swcp.com> hudson@swcp.com (Tramm Hudson) writes:
>[ Posted and cc'd to cited author ]
>Mark Jason Dominus <mjd@plover.com> wrote:
>>Konstantinos Agouros <elwood@news.agouros.de> wrote:
>>> ... open(DESK,"tail -f /var/log/messages|") ...
>>
>>I use:
>[snip the code example]
>Is there something wrong with the answer given by
> perldoc -q 'tail -f'
That was what I meant by 'missing something' \:)
>Other than that your example does support multiple files and
>shows how to use gensym rather than File::Handle.
>> I have no idea about the efficiency.
>Does efficiency really matter if the code does a "sleep 5" in a loop?
actually the files I am going to work on might be quite busy... so sleep might
not be the best Idea... however I didn't know the seek-part from the faq.
Thanks,
Konstantin
>Tramm
>--
> o hudson@swcp.com hudson@turbolabs.com O___|
> /|\ http://www.swcp.com/~hudson/ H 505.323.38.81 /\ \_
> << KC5RNF @ N5YYF.NM.AMPR.ORG W 505.986.60.75 \ \/\_\
> 0 U \_ |
--
Dipl-Inf. Konstantin Agouros aka Elwood Blues. Internet: elwood@agouros.de
Otkerstr. 28, 81547 Muenchen, Germany. Tel +49 89 69370185
----------------------------------------------------------------------------
"Captain, this ship will not sustain the forming of the cosmos." B'Elana Torres
------------------------------
Date: Sun, 27 May 2001 20:59:27 GMT
From: Daryl Shute <daryl.shute@pss.boeing.com>
Subject: Re: Time validation
Message-Id: <3B116AAF.22C83374@pss.boeing.com>
--------------23F45DC3C05EB6A7466D70DE
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Sorry Godzilla,
Here is the code in trying, and YES sometimes even in a 24 hour intranet world
things wont get done without human intervention.
sub BEGIN {
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime;
$thisday = ("Sun","Mon","Tue","Wed","Thu","Fri","Sat")[(localtime)[6]];
if ($thisday =~ /Sun/ || $thisday =~ /Sat/)
{
print "All Analysts are out of the office on the weekends,\n";
print "Please call Recovery for assistance. \n";
} if (($hour == 15) && ($min >= 15))
{
print "it's $hour:$min (15:15 was closing time) Please call
Recovery for assistance.\n";
}
elsif ( $hour > 15)
{
print "it's $hour:$min (15:15 was closing time) Please call
Recovery for assistance.\n";
}
elsif (( $hour >= 6) && ($hour <= 15) )
{
print "it's $hour:$min (after 6am) submit the form !\n";
}
else
{
print"something's wrong\n";
}
{
####The rest of the code goes here#####
}
Daryl Shute
"Godzilla!" wrote:
> Daryl Shute wrote:
>
> (snipped)
>
> > I have a form that needs to be submitted only during the hours of 0600 -
> > 1515 Monday through Friday, and not on Holidays. If the time or date is not
> > in this time frame I need to send the user to another WebPage, otherwise
> > allowing the user to continue on with the form submission.
>
> This is highly illogical and is most contrary to this concept of
> the internet being "open for business" around the clock, even if
> an intranet rather than the internet.
>
> Clearly your system is running twenty-four hours a day with this
> form always being available, as indicated by your implied parameters.
> A form action requires no human intervention. Your form action on
> this system is available, so is your associated script and any
> required data base along with disk storage ability for data
> submission, all indicated by your ability to redirect. There
> exists no logical reason to disallow use of a form action based
> upon a temporal basis.
>
> Should you respond with logic of "Human intervention is required."
> My response will be, "Why?"
>
> Ignoring your lack of logic, you have stated no parameters. You
> have not stated if this is local time or time relative to Greenwich
> Mean Time. There is no indication if you are in a time zone affected
> by Daylight Savings Time. Most important, you have provided zero
> parameters regarding what days constitute a holiday.
>
> Post your code you have written thus far to address these issues.
>
> Godzilla!
--------------23F45DC3C05EB6A7466D70DE
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
Sorry Godzilla,
<br>Here is the code in trying, and YES sometimes even in a 24 hour intranet
world things wont get done without human intervention.
<p>sub BEGIN {
<p>($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime;
<p>$thisday = ("Sun","Mon","Tue","Wed","Thu","Fri","Sat")[(localtime)[6]];
<br> if ($thisday =~ /Sun/ || $thisday =~ /Sat/)
<br> {
<br> print "All Analysts are out of the office on the weekends,\n";
<br> print "Please call Recovery for assistance. \n";
<br> } if (($hour == 15) && ($min >= 15))
<br> {
<br>
print "it's $hour:$min (15:15 was closing time) Please call Recovery for
assistance.\n";
<br>
<br> }
<br> elsif ( $hour > 15)
<br> {
<br>
print "it's $hour:$min (15:15 was closing time) Please call Recovery for
assistance.\n";
<br>
<br> }
<br> elsif (( $hour >= 6) &&
($hour <= 15) )
<br> {
<br>
print "it's $hour:$min (after 6am) submit the form !\n";
<br>
<br>
<br> }
<br> else
<br> {
<br>
print"something's wrong\n";
<br> }
<br>
<br>{
<br>####The rest of the code goes here#####
<br>}
<p><a href="mailto:daryl.shute@pss.boeing.com">Daryl Shute</a>
<br>
<p>"Godzilla!" wrote:
<blockquote TYPE=CITE>Daryl Shute wrote:
<p>(snipped)
<p>> I have a form that needs to be submitted only during the hours of
0600 -
<br>> 1515 Monday through Friday, and not on Holidays. If the time or date
is not
<br>> in this time frame I need to send the user to another WebPage, otherwise
<br>> allowing the user to continue on with the form submission.
<p>This is highly illogical and is most contrary to this concept of
<br>the internet being "open for business" around the clock, even if
<br>an intranet rather than the internet.
<p>Clearly your system is running twenty-four hours a day with this
<br>form always being available, as indicated by your implied parameters.
<br>A form action requires no human intervention. Your form action on
<br>this system is available, so is your associated script and any
<br>required data base along with disk storage ability for data
<br>submission, all indicated by your ability to redirect. There
<br>exists no logical reason to disallow use of a form action based
<br>upon a temporal basis.
<p>Should you respond with logic of "Human intervention is required."
<br>My response will be, "Why?"
<p>Ignoring your lack of logic, you have stated no parameters. You
<br>have not stated if this is local time or time relative to Greenwich
<br>Mean Time. There is no indication if you are in a time zone affected
<br>by Daylight Savings Time. Most important, you have provided zero
<br>parameters regarding what days constitute a holiday.
<p>Post your code you have written thus far to address these issues.
<p>Godzilla!</blockquote>
</html>
--------------23F45DC3C05EB6A7466D70DE--
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
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.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.
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 V10 Issue 999
**************************************