[12957] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 367 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Aug 4 15:07:24 1999

Date: Wed, 4 Aug 1999 12:05:13 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Wed, 4 Aug 1999     Volume: 9 Number: 367

Today's topics:
    Re: [offtopic]RE:Quot St and the Jeop Gm (Malcolm Ray)
    Re: [offtopic]RE:Quot St and the Jeop Gm (Larry Rosler)
    Re: [offtopic]RE:Quot St and the Jeop Gm <revjack@radix.net>
    Re: Adding time (David H. Adler)
    Re: CGI.pm Example <geoffrey.halliwell@Sun.COM>
    Re: chomp not working <sariq@texas.net>
    Re: chomp not working (Bart Lateur)
    Re: defconfaq - Q&A on arguments against the hypothetic (Reini Urban)
    Re: download available <cassell@mail.cor.epa.gov>
    Re: Escaping HTML tags (Larry Rosler)
        Help me .........please!! hads6307@my-deja.com
        Help me.....Please!!!!!!!!!!!!!!! hads6307@my-deja.com
    Re: Help me.....Please!!!!!!!!!!!!!!! <Mark@Mark.Com>
    Re: How to access only last field of a split ? (Larry Rosler)
    Re: how to check if scalar is blank? <cassell@mail.cor.epa.gov>
        How to kill a process under win32 <mkarner@sbox.tu-graz.ac.at>
    Re: Jeoparder's Jest (Matthew R. Williams)
    Re: looking for XML comments <jcreed@cyclone.jprc.com>
    Re: mySQL & Perl -> Something simple <perlking@hotmail.com>
    Re: Newbie: how do I send shell script output to my per <agno3@ionet.net>
    Re: open3 and print to STDOUT <cassell@mail.cor.epa.gov>
    Re: Perl counter muckup (Larry Rosler)
        Digest Administrivia (Last modified: 1 Jul 99) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: 4 Aug 1999 18:26:32 GMT
From: M.Ray@ulcc.ac.uk (Malcolm Ray)
Subject: Re: [offtopic]RE:Quot St and the Jeop Gm
Message-Id: <slrn7qh1eo.4om.M.Ray@carlova.ulcc.ac.uk>

On 04 Aug 1999 10:48:33 -0600, llornkcor@earthlink.net
<llornkcor@earthlink.net> wrote:
>lr@hpl.hp.com (Larry Rosler) writes:
>
>>> Maybe you don't know how to use 'perldoc'. Or perhaps you work on a
>>> winblows machine that doesn't offer little useful utilities such as
>>> 'grep'.
>
>hmm, maybe there isn't very good info on using perldoc? Oh, there's a
>few explainations on perldoc perl, but where's perldoc perldoc??? :o)

$ perldoc perldoc

PERLDOC(1)     User Contributed Perl Documentation     PERLDOC(1)


NAME
       perldoc - Look up Perl documentation in pod format.

SYNOPSIS
       perldoc [-h] [-v] [-t] [-u] [-m] [-l] [-F]  [-X]
       PageName|ModuleName|ProgramName

       perldoc -f BuiltinFunction

       perldoc -q FAQ Keyword

etc.  Works for me.  If it doesn't work for you, complain to whoever
installed Perl on your system.

-- 
Malcolm Ray                           University of London Computer Centre


------------------------------

Date: Wed, 4 Aug 1999 11:13:59 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: [offtopic]RE:Quot St and the Jeop Gm
Message-Id: <MPG.121222c0fa0f4a3a989dbf@nntp.hpl.hp.com>

In article <wkyafrv6e6.fsf@earthlink.net> on 04 Aug 1999 10:48:33 -0600, 
llornkcor@earthlink.net <llornkcor@earthlink.net> says...
> lr@hpl.hp.com (Larry Rosler) writes:
> 
> >> Maybe you don't know how to use 'perldoc'. Or perhaps you work on a
> >> winblows machine that doesn't offer little useful utilities such as
> >> 'grep'.

That quote is incorrectly attributed.  I didn't write it -- I was 
quoting it.  But you are making progress in newsreader use, 
nevertheless!

> hmm, maybe there isn't very good info on using perldoc? Oh, there's a
> few explainations on perldoc perl, but where's perldoc perldoc??? :o)

Did you try it before posting? `perldoc perldoc` works just fine, even 
on my Windows NT system.

> my windlows system has grep...
> and also ls, sort and a bunch of unix commands.
> but I am not talking about a windblows system, I am talking linux.

My Windows NT and Windows 95 systems all have grep...
and also ls, sort and a bunch of unix commands.  What I wrote was about 
'Find', which is available to any Windows user, without their having to 
acquire and install POSIX tools.

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


------------------------------

Date: 4 Aug 1999 18:46:59 GMT
From: revjack <revjack@radix.net>
Subject: Re: [offtopic]RE:Quot St and the Jeop Gm
Message-Id: <7oa1r3$nh8$1@news1.Radix.Net>
Keywords: Hexapodia as the key insight

Tom Christiansen explains it all:

:In comp.lang.perl.misc, 
:    llornkcor@earthlink.net (llornkcor@earthlink.net) writes:
:: I happen to _prefer_ where the comment is before the quoted text, that
::way I dont have to scroll through it all. Personal choose.

:Trim, interpolate, and summarize.

"Don't just follow up -- *compose* a reply" - me


------------------------------

Date: 4 Aug 1999 14:19:33 -0400
From: dha@panix.com (David H. Adler)
Subject: Re: Adding time
Message-Id: <slrn7qh11k.bah.dha@panix.com>

On Wed, 4 Aug 1999 13:16:59 +1000, elephant <elephant@squirrelgroup.com> wrote:
>
>hmm .. 'epoch seconds' I've heard .. 'epoch time' I aint never heard .. 
>see time isn't really relative to the epoch .. so 'epoch time' doesn't 
>really make sense .. but the number of seconds since the epoch does - 
>hence 'epoch seconds'

Actually, time is utterly arbitrary.  It can be relative to anything
you want.  When talking un*x, I have no trouble with "epoch time"
meaning "time in seconds since [whatever the system takes as the
beginning of time...]".

My god... I actually got to use that Philosophy of Science degree...
I'm in shock.  :-/

-- 
David H. Adler - <dha@panix.com> - http://www.panix.com/~dha/
"Your point being..." - Homer Simpson


------------------------------

Date: Wed, 04 Aug 1999 10:51:57 -0700
From: Geoff Halliwell <geoffrey.halliwell@Sun.COM>
To: abigail@delanet.com
Subject: Re: CGI.pm Example
Message-Id: <37A87DBD.8446A25C@Sun.COM>

Abigail wrote:
> 
> GEOFFREY HALLIWELL (GEOFFREY.HALLIWELL@Sun.COM) wrote on MMCLXII
> September MCMXCIII in <URL:news:37A5B78C.AC8C4CD5@Sun.COM>:
> ^^ Hi,
> ^^
> ^^ I'm trying to run one of Lincoln Stein's CGI.pm examples
> ^^ (see below) and it won't allow me to view or
> ^^ write to the guestbook file.  It is unable to secure
> ^^ the lock on the file system so it bails with "Sorry, an
> ^^ error occurred: unable to open  guestbook file."
> ^^
> ^^ Any ideas?
> 
> So, what's $! set to?
> 
> Abigail

$! returns "Bad File Number" when you submit and entry,
and returns nothing when you try to view the guestbook.

Geoff


------------------------------

Date: Wed, 04 Aug 1999 13:19:03 -0500
From: Tom Briles <sariq@texas.net>
Subject: Re: chomp not working
Message-Id: <37A88417.113EF750@texas.net>

jembow@my-deja.com wrote:
> 
> Just learning Perl, each time i try to use chomp i get the following error:
> 
> ""chomp" may clash with future reserved word at ./chomp_test line
> 3syntax error i
> n file ./chomp_test at line 3, next 2 tokens "chomp("
> Execution of ./chomp_test aborted due to compilation errors."
> 
> I'm using perl5.00502 on FreeBSD 2.2.8

Are you sure about that?  Let's see a code snippet, please.

- Tom


------------------------------

Date: Wed, 04 Aug 1999 18:47:25 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: chomp not working
Message-Id: <37a88a3f.620158@news.skynet.be>

jembow@my-deja.com wrote:

>Just learning Perl, each time i try to use chomp i get the following error:
>
>""chomp" may clash with future reserved word at ./chomp_test line 
>3syntax error in file ./chomp_test at line 3, next 2 tokens "chomp("
>Execution of ./chomp_test aborted due to compilation errors."
>
>I'm using perl5.00502 on FreeBSD 2.2.8

Are you absolutely sure? It sounds like Perl4.

Try this in a script:

	#! /usr/local/bin/perl -v

	Bart.


------------------------------

Date: Wed, 04 Aug 1999 19:03:01 GMT
From: rurban@xarch.tu-graz.ac.at (Reini Urban)
Subject: Re: defconfaq - Q&A on arguments against the hypothetical ?? operator
Message-Id: <37a88dd9.4144429@judy.x-ray.local>

Gareth Rees <garethr@cre.canon.co.uk> wrote:

>Tom Christiansen <tchrist@mox.perl.com> wrote:
>> But it's not just C that has macros, and other implementations are not
>> so frequently denigrated--nor if truth be told, so well known. For
>> example, Franz Liszt, a dialect of Lisp, had macros.

Franz Lisp is no dialect, it is THE standard common lisp.

>If the Perl developers are thinking about adding macros - or functions
>which receive arguments unevaluated - then it would be a mistake not to
>learn from the Lisp and Scheme families of languages.

esp. the object system's syntax would benefit from macros, since macros
are mostly only a rewrite from ugly and verbose looking code into short
user-readable code, a feature which perl lacks for sure.
--
Reini Urban
http://xarch.tu-graz.ac.at/autocad/news/faq/autolisp.html


------------------------------

Date: Wed, 04 Aug 1999 11:37:39 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
To: joel@dalleyjo.user.msu.edu
Subject: Re: download available
Message-Id: <37A88873.74EE40D@mail.cor.epa.gov>

[courtesy cc e-mailed to poster]

Joel wrote:
> 
> Jonathan Stowe wrote:
[snip of critique]

> Well - take it or leave it, I guess. I'm simply offering it up; certainly

Joel, please be fair.  You submitted this to a *programming*
newsgroup, and programmers looked at it.  Everyone here looks
at code and tries to help improve it.  Even frequent posters
[like Jonathan and myself] are not immune from code-review,
nor should we be.  There are some serious flaws in your
program, and you can fix them with a little guidance.  That
should be a *good* thing.

> someone in this world besides
> myself will find it useful. Concerning the reference to Matt Wright, is that
> a slam or a compliment.

That's a *major* slam around here.  Matt Wright has released
a lot of code, and as a result a lot of bad Perl-things have
been spread around the Net.  His code isn't robust, and does
a lot of things the wrong way.  As far as I know, there were
Y2K problems with at least one of his scripts as recently as
two months ago.

>                          I ask
> only because he's been doing this for a long time now and I've been web
> programming / using Perl
> for about a month and a half; this program is my first web app.

And your code is already nearing his level, which is not yet
a compliment.  But if you want to get better at Perl (or at
any other language), you have to write Perl programs and read
*good* Perl books and let experts give you advice.

I suggest you look at the "Perl Cookbook", "Learning Perl" and/or
"Programming Perl" depending on your level, and "Effective Perl
Programming".  Some other places to look would be Randal Schwartz's
columns from WebTechniques and Unix Review, which are reproduced
on his website [ www.stonehenge.com/~merlyn/ ].  And read this
newsgroup, including archives from deja.com .  You can learn
a lot from the code of the gurus, including defensive programming
to handle that one time in a hundred when your file doesn't
open properly.

Every one of Jonathan's comments is valid, and could be helpful.
Really.  I know accepting criticisms isn't any fun, but part
of being a programmer is having other people look at your code
and make suggestions.. or sometimes just send you a rude email
telling you what to do with your code.  Look up Larry Wall's
three virtues of programming, and I think you'll see the Perl
Way in there.

>                                                            Think back
> to when you were that far along and what you'd done to date...

Umm.. maybe it was:
   perl -e 'print "Hello World!;"'
:-)

A lot of the code I wrote in my first couple months has been
completely re-written.  How did I learn better?  Having someone
tell me what was wrong, and what was sub-optimal.

HAND,
David
-- 
David Cassell, OAO                     cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician


------------------------------

Date: Wed, 4 Aug 1999 11:19:25 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Escaping HTML tags
Message-Id: <MPG.12122407a9b80953989dc0@nntp.hpl.hp.com>

In article <7o92gi$38j$1@nntp0.reith.bbc.co.uk> on Wed, 4 Aug 1999 
10:50:54 +0100, James Williamson <james.williamson@bbc.co.uk> says...
> Abigail wrote in message ...
 ...
> >
> >perl -wi -pe 's.<.&lt;.g' file
> >              0123456789
> >
> >There's never a need to escape " or > if the effect you are after is
> >to make HTML tags visible. Knowing the field you play on helps in both
> >golf and Perl golf. ;-)
> >
> >Abigail
> >--
> 
> As you so often rightly stress, you can find it all in the perl
> documentation;
> perldoc perlrun.

Say what?  'all'???  The discussion isn't about the -wi -pe'.  It's 
about the substitution, which perlrun doesn't deal with.

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


------------------------------

Date: Wed, 04 Aug 1999 18:25:43 GMT
From: hads6307@my-deja.com
Subject: Help me .........please!!
Message-Id: <7oa0io$pg6$1@nnrp1.deja.com>

Can somebody help me with this problem?  I need to take input from a
single textbox in a form and output the data into another frame.  Can
somebody help with the framework below.


Mike


#!/usr/bin/perl
# load CGI library
use CGI qw(:standard);

#Create header

#Capture form input and save into scalar variable
if ( $method eq 'POST' )
{
print "HI THERE";
read(STDIN, $_, $ENV{'CONTENT_LENGTH'});
}


# set condition so that if input is not equal to "" print "You are
thinking <input>"

#else print out ""



Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


------------------------------

Date: Wed, 04 Aug 1999 18:23:43 GMT
From: hads6307@my-deja.com
Subject: Help me.....Please!!!!!!!!!!!!!!!
Message-Id: <7oa0f1$pdm$1@nnrp1.deja.com>

Can somebody help me with this problem?  I need to take input from a
single textbox in a form and output the data into another frame.  Can
somebody help with the framework below.


Mike


#!/usr/bin/perl
# load CGI library
use CGI qw(:standard);

#Create header

#Capture form input and save into scalar variable
if ( $method eq 'POST' )
{
print "HI THERE";
read(STDIN, $_, $ENV{'CONTENT_LENGTH'});
}


# set condition so that if input is not equal to "" print "You are
thinking <input>"

#else print out ""



Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


------------------------------

Date: Wed, 04 Aug 1999 19:59:49 +0100
From: Mark <Mark@Mark.Com>
Subject: Re: Help me.....Please!!!!!!!!!!!!!!!
Message-Id: <37A88DA5.BDE75EBE@Mark.Com>



hads6307@my-deja.com wrote:

> Can somebody help me with this problem?  I need to take input from a
> single textbox in a form and output the data into another frame.  Can
> somebody help with the framework below.
>
> Mike
> snipped lots of stuff

Right,

From your script you are using the CGI module. This is good but you are
not taking advantage of it. You are still using print <blah>

Try the following link

http://stein.cshl.org/WWW/software/CGI/cgi_docs.html#frames

Note particularly
<quote>
Using frames effectively can be tricky. To create a proper frameset in
which the query and response are displayed side-by-side requires you to
divide the script into
three functional sections. The first section should create the <frameset>
declaration and exit. The second section is responsible for creating the
query form and
directing it into the one frame. The third section is responsible for
creating the response and directing it into a different frame.

The examples directory contains a script called popup.cgi that
demonstrates a simple popup window. frameset.cgi provides a skeleton
script for creating
side-by-side query/result frame sets.
^^^^^^^^^^^^^^^^^^^^^^^
</quote>

Use CGI fully. It will save you heaps of hassle in the long run. Never,
ever write a CGI script with $method eq 'POST'. You shouldn't need to
know or care about such things.

Read the CGI documentation carefully. Well worth a few hours with your
head in a towel.



------------------------------

Date: Wed, 4 Aug 1999 11:06:58 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: How to access only last field of a split ?
Message-Id: <MPG.12122122cd9a8c43989dbe@nntp.hpl.hp.com>

In article <7o9sdl$c2@enews3.newsguy.com> on Wed, 4 Aug 1999 12:14:34 -
0500, Sam Weatherhead <sweather@fastenal.com> says...
> If I'm understanding you right, when you do a split the results get thrown
> into an array.
> If you then want to access only the last element of the array, just use the
> name of the
> array but with a $# in front of it as the subscript.
> 
> Example:
> 
> $String = "1,2,3,4,5,6,7,8,9,10";
> @Simple_Array = split( "," , $String );
> $Last_Field = $Simple_Array[ $#Simple_Array ];

You are about three days behind those who have already pointed out that 
you don't need to save the whole array -- just use the '-1' subscript.

  $String = "1,2,3,4,5,6,7,8,9,10";
  $Last_Field = (split /,/, $String)[-1];

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


------------------------------

Date: Wed, 04 Aug 1999 11:12:48 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: how to check if scalar is blank?
Message-Id: <37A882A0.1B51FE92@mail.cor.epa.gov>

Anno Siegel wrote:
> 
> Paul Glidden <paul.glidden@unisys.com> wrote in comp.lang.perl.misc:
[snip]
> There isn't any initialization shown in what you posted.  And if
> there were, assigning a value to the scalar that it will "most
> likely" never have isn't good enough.  It will break some day.

More specifically, it *will* break on the day you do that live
demo in front of the CIO, and a marketing guy types in something
no one would ever be dumb enough to enter.  Oops.

David
-- 
David Cassell, OAO                     cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician


------------------------------

Date: Wed, 04 Aug 1999 20:33:15 +0200
From: Michael Karner <mkarner@sbox.tu-graz.ac.at>
Subject: How to kill a process under win32
Message-Id: <37A8876B.C2120F83@sbox.tu-graz.ac.at>

Hi,

I'm writing a perl script which launches other scripts, the problem is
that I don't know how to kill this processes (if e.g. the process needs
more than 30 minutes)  to come back to the main script and write the
failure to a log file. Can anyone give me hint?

Thanks!




------------------------------

Date: 03 Aug 1999 23:43:11 -0500
From: mrw@groogroo.com (Matthew R. Williams)
Subject: Re: Jeoparder's Jest
Message-Id: <x7iu6w17hc.fsf@number-two.aus.groogroo.com>

Tom Christiansen <tchrist@mox.perl.com> writes:

> # Now, what's the question? :-)

Am I the only person in this newsgroup who has the distinct impression
that Tom has snapped?  That he's finally crossed into the great beyond
from whence such concepts as "GNU/Linux" and "Python" originated?  The
land of the truly insane?  Should we weave a circle around him thrice?

So sorry...four questions.  

(Sidebar for the humor impaired:  I'm having a great time watching Tom,
and long ago created a killfile for Gnus that takes care of 30% of the
traffic on this newsgroup...but I am worried that he let a prescription 
lapse, and am slightly worried that the Good Name of Perl will be
tarnished by his harsh but deserved criticism towards...well...anything
that moves.)



-M<
-- 
It's psychosomatic.  You need a lobotomy.  I'll get a saw. 
		-Calvin
--------------------------------------------------------
Matt Williams                          mrw@groogroo.com
Keeper of the Fun          http://www.groogroo.com/~mrw/
--------------------------------------------------------


------------------------------

Date: 04 Aug 1999 14:03:42 -0400
From: Jason Reed <jcreed@cyclone.jprc.com>
Subject: Re: looking for XML comments
Message-Id: <a1672vs9s1.fsf@cyclone.jprc.com>

David Cassell <cassell@mail.cor.epa.gov> writes:
> Can we still discuss the Spanish Inquisition?

I'd expect not.

---Jason


------------------------------

Date: Wed, 04 Aug 1999 14:32:20 EDT
From: "Perl King" <perlking@hotmail.com>
Subject: Re: mySQL & Perl -> Something simple
Message-Id: <19990804183220.21573.qmail@hotmail.com>

Larry Rosler wrote:
>>Steve MacLellan <maclell@col.ca> says...
>> > On Tue, 3 Aug 1999 18:27:23 -0700, lr@hpl.hp.com (Larry Rosler) wrote:
>> >
>> >This is off-topic, but the </TD>, </TH>, and </TR> tags are all
>> >optional. So the </TD> there is just HTML noise.
>>
>>Yes, optional if you only want it to dsiplay in MSIE. If you want it
>>to display in Netscape you have to close Table elements.
>
>Getting further off-topic, so I'll keep it brief.
>
>NO!

Netscape advises authors to close the TR and TD containers. Some
authors have had problems with tables within tables if they fail
to comply with this advice.

Some older browsers (that don't support tables) will give up
or even crash (with stack overflow) if you don't close those containers. So 
there can be advantages in not omitting those
optional tags.

ObPerl: Use the => operator only in hash initialization.

Perl King


_______________________________________________________________
Get Free Email and Do More On The Web. Visit http://www.msn.com


------------------------------

Date: Wed, 04 Aug 1999 13:13:16 -0500
From: Brett Zimmerman <agno3@ionet.net>
Subject: Re: Newbie: how do I send shell script output to my perl program?
Message-Id: <37A882BC.E5CF0539@ionet.net>



Russell Zah wrote:
> 
> Hi,
> 
> How do I send a shell script's output to my perl program for processing?
> 
> It's sort of complex because my boss had me write a shell program to get
> data out of an SQL database, then take that data and use the perl
> program to format it and put it up on a webpage.
> 
> Thanks,
> 
> Russell

a pipe?

-bz


------------------------------

Date: Wed, 04 Aug 1999 11:06:30 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: open3 and print to STDOUT
Message-Id: <37A88126.6BEEEE97@mail.cor.epa.gov>

Pavel Kotala wrote:
> 
> When I use Open3 (on WinNT), and then print to stdout, then message is shown
> at the end of script, not just at the moment of printing. For example in the
> example below, running this script I see message 1, then I must press key
> and then I see messages 2 and 3.
> 
> Any Idea why? How can I do it work?

This is due to buffering.  For more details, type this:

   perldoc -q buffer

and then add this to your program:

$|=1;

[snip of program]

HTH,
David
-- 
David Cassell, OAO                     cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician


------------------------------

Date: Wed, 4 Aug 1999 11:48:58 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Perl counter muckup
Message-Id: <MPG.12122af8bc715eab989dc2@nntp.hpl.hp.com>

[Posted and a courtesy copy mailed.]

In article <7o9gmh$cri$1@nnrp1.deja.com> on Wed, 04 Aug 1999 13:54:30 
GMT, Richard Lawrence <ralawrence@my-deja.com> says...
> I have written a small webpage counter (no big deal) in Perl and yet
> every so often it resets itself (well, it reset itself today and had
> been going for about 7 months before then). I've come to the not-so-
> unreasonable conclusion that its my perl that is at fault. Could anyone
> point me to what I've done wrong that makes this counter currently
> unreliable please?

Others may rag on you about this.  Having worked for a long time on a 
highly reliable and useful access monitoring system for users who don't 
have access to server logs, I certainly won't!

> # realised that I have no idea how to just read one line from
> # a file - this seems to work although I suspect its bad perl.
> 
> open (SITE, "counter.dat");
                            ^ or die " ... $!\n"

But see below for A Better Way.

> $_ = <SITE>;  # urg?

That is a perfectly fine way to read one line from a file.

 ...

> # write out new data - loop for lock
> 
> open (SITE, ">counter.dat") || die "can't!";
> my $locked = 0;
> while ($locked == 0)  # could technically loop for ever.
> {
>   if (flock(SITE, LOCK_EX))
>   {
>     $locked = 1;
>   }
> }

I think this problem is handled best by opening the file once, for read-
write ('+<counter.dat'), getting the lock, reading the file, rewinding 
and truncating it, then writing and closing it.  That way, you are in 
essence dealing with an atomic transaction.

As for the potentially infinite loop, `perldoc -f alarm`.

> printf SITE "$details[0] $from\n";

Don't use 'printf' unless there is a conversion specification in the 
format.  Use 'print'.

> close SITE;
> 
> # display info
> 
> printf "Content-type: text/html\n\n";
> printf("%d\n", $details[0]);

Don't use 'printf' unless there is a conversion specification in the 
format.  Use 'print'.

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


------------------------------

Date: 1 Jul 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 1 Jul 99)
Message-Id: <null>


Administrivia:

The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc.  For subscription or unsubscription requests, send
the single line:

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.

The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.

The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.

For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V9 Issue 367
*************************************


home help back first fref pref prev next nref lref last post