[16578] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3990 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Aug 11 18:07:32 2000

Date: Fri, 11 Aug 2000 15:05:38 -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: <966031537-v9-i3990@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Fri, 11 Aug 2000     Volume: 9 Number: 3990

Today's topics:
    Re: 'require'd functions access main variables (Anno Siegel)
    Re: 'require'd functions access main variables <ab@cd.com>
    Re: Best practices.... <lr@hpl.hp.com>
    Re: Best practices.... <lauren_smith13@hotmail.com>
    Re: Best practices.... (Andrew Johnson)
    Re: Best practices.... <godzilla@stomp.stomp.tokyo>
    Re: Best practices.... <lmoran@wtsg.com>
    Re: Best practices.... <lauren_smith13@hotmail.com>
    Re: Best practices.... <lmoran@wtsg.com>
    Re: Best practices.... (Andrew Johnson)
    Re: Best practices.... <care227@attglobal.net>
    Re: Best practices.... <godzilla@stomp.stomp.tokyo>
    Re: Best practices.... <godzilla@stomp.stomp.tokyo>
    Re: Best practices.... <smerr612@mailandnews.com>
        can't read file handle <mail@mail.com>
    Re: can't read file handle <care227@attglobal.net>
    Re: can't read file handle <newsposter@cthulhu.demon.nl>
    Re: CGI, How to get back to cached dokument <dominique.plu@ifrance.com>
        Checking the IP and reverse <hermann@wecke.de>
    Re: Converting from US dates/numbers to European dates/ (Abigail)
    Re: Converting from US dates/numbers to European dates/ (Abigail)
    Re: Cross-platform shebang line CGI script shenanigans  <jeff@vpservices.com>
    Re: Cross-platform shebang line CGI script shenanigans  (Doran)
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: 11 Aug 2000 18:16:01 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: 'require'd functions access main variables
Message-Id: <8n1ft1$99c$1@lublin.zrz.tu-berlin.de>

Blair Heuer <ab@cd.com> wrote in comp.lang.perl.misc:
>> Ugh.  Despite its name, $global, declared with my(), is a variable
>> with lexical scope, meaning it is invisible outside the block is
>> is declared in.  In this case the block, in absence of surrounding {},
>> is the file.  So you have just made sure that $global is invisible
>> to a subroutine that's defined in another file.
>
>> This is another point.  Under "strict vars", you'd have to fully qualify
>> the variable name: $main::global.
>
>I just used "$global" for no reason, not thinking the name would make it
>global. While using 'use strict' I have to declare variables with 'my' or
>else I get an error. How do I declare the variable and still get it to be
>accessable elsewhere?

our $global; # Perl 5.6
use vars '$global'; # earlier Perls

Anno


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

Date: Fri, 11 Aug 2000 18:32:32 GMT
From: "Blair Heuer" <ab@cd.com>
Subject: Re: 'require'd functions access main variables
Message-Id: <4FXk5.1127$IH.38918@newsread2.prod.itd.earthlink.net>

> How do I declare the variable and still get it to be
> accessable elsewhere?

Okay, I finally figured it out. I was always using 'my $var;' when I should
have been using '$main::var'.

Now just to completely start my project over again to avoid fixing over old
problems. ;)

Thanks for everyone's input.

-Blair




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

Date: Fri, 11 Aug 2000 11:17:53 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Best practices....
Message-Id: <MPG.13fde32ec7bfed4898ac6c@nntp.hpl.hp.com>

In article <6yqUOdNhqAAHDDxoguXX6WOM90lZ@4ax.com> on Fri, 11 Aug 2000 
12:42:37 -0400, Lou Moran <lmoran@wtsg.com> says...
> ...I am not a programmer, though I sometimes program things.

Then you *are* a programmer -- amateur, not professional, perhaps; but a 
programmer nonetheless.

> ...I read a fair amount of O'Reilly's but I used Elements of
> Programming with Perl to really get things going.

That is a great way to start out.

> Apparently my code is ugly.  I would like to know where I can get a
> good best practices guide, lesson, clue, so that my code is less
> offensive.

'Apparently' -- who is judging?

The Perl Cookbook would be a good place to find 'inoffensive' code.

> When I am in NT I use UltraEdit to write in, and Xemacs when I am in
> Linux (although I just got Xemacs for NT so I might switch)
> 
> Here is an example:  (I didn't comment anything b/c even I can figure
> out what it means) (this was a lesson from EoPwP)
> 
> #!/usr/bin/perl -w
> use strict;

You pass the course already!

> my ($rate, $otrate, $regular, $overtime, $pay);

That style of predeclaration comes from old C.  Most Perl programmers 
would use a more C++-ish style of declaring variables where they are 
first used.  One justification for the predeclaration style would be to 
list the variables one on a line, each with a descriptive comment.  But 
you aren't doing that.
 
> print "Enter your hourly rate: \n";
> $rate = <STDIN>;
> chomp ($rate);

Nothing wrong with that.  But golfers might write:

  chomp(my $rate = <STDIN>);

 ...

> $otrate = $overtime * $rate * 1.5;
> $regular = $regular * $rate;

There is a *= operator.  But so what?

> $pay = $regular + $otrate;
> 
> print "Your gross pay for this period is $pay. \n";

Depending on the arithmetic, you may end up with more fractional digits 
in the result than you want.  Use printf() to deal with that.  Or 
(better) do all money calculations with integer cents, then divide by 
100 at the last moment.  You still need printf() to force two fractional 
digits, though.

The space before the newline doesn't do much (here or in your code 
above).  But so what?

The code you posted is unremarkable.  Certainly not offensive.

Paranoia will destroy ya'.

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


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

Date: Fri, 11 Aug 2000 11:20:21 -0700
From: "Lauren Smith" <lauren_smith13@hotmail.com>
Subject: Re: Best practices....
Message-Id: <8n1g1v$fcv$1@brokaw.wa.com>


Lou Moran <lmoran@wtsg.com> wrote in message
news:6yqUOdNhqAAHDDxoguXX6WOM90lZ@4ax.com...
> ...I am not a programmer, though I sometimes program things.

I'm not a driver, but sometimes I drive my car.  ;-)  You are what you do,
I've always thought.

> Apparently my code is ugly.  I would like to know where I can get a
> good best practices guide, lesson, clue, so that my code is less
> offensive.
>
> Here is an example:  (I didn't comment anything b/c even I can figure
> out what it means) (this was a lesson from EoPwP)
>
> #!/usr/bin/perl -w
> use strict;
>
> my ($rate, $otrate, $regular, $overtime, $pay);
>
> print "Enter your hourly rate: \n";
> $rate = <STDIN>;
> chomp ($rate);
>
> print "Enter your regular hours: \n";
> $regular = <STDIN>;
> chomp ($regular);
>
> print "Enter your overtime hours: \n";
> $overtime = <STDIN>;
> chomp ($overtime);
>
> $otrate = $overtime * $rate * 1.5;
> $regular = $regular * $rate;
> $pay = $regular + $otrate;
>
> print "Your gross pay for this period is $pay. \n";

This code isn't at all ugly.  It maybe a little verbose, but it's very
clear.

For tips on Perl programming style, see the perlstyle documentation.  Type
'perldoc perlstyle' at your command prompt.  If you want to read it in HTML
format on Windows, Start->Program Files->ActivePerl->Online Documentation,
then scroll down the left pane to 'perlstyle'.

Welcome to Perl, I hope you enjoy your stay!

Lauren
--
print grep ord $_,map{y/a-z//d;$x.="+ $_";chr(eval $x)}
'J74u43-s2tA1-84n33o45th1er5-12-P3e13-82r48l21H13-a6-76
c40k25er2wx8-y6z13-81'=~m#([^!\n]{3})#g#tr/-0-9//d;print





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

Date: Fri, 11 Aug 2000 18:35:51 GMT
From: andrew-johnson@home.com (Andrew Johnson)
Subject: Re: Best practices....
Message-Id: <bIXk5.22235$k5.224939@news1.rdc1.mb.home.com>

In article <6yqUOdNhqAAHDDxoguXX6WOM90lZ@4ax.com>,
 Lou Moran <lmoran@wtsg.com> wrote:

[snip]

! Apparently my code is ugly.  I would like to know where I can get a
! good best practices guide, lesson, clue, so that my code is less
! offensive.

Who says it's ugly? Lemme at 'em, lemme at 'em!

Seriously, I've looked at the example you included and it is not
substantially different from the solution I provide for that
exercise.

I generally do not put newlines at the end of my prompt-strings, and
I'd likely declare the variables as needed rather than all at the
top. I'd also combine the chomp() and input assignment in the same
statement:

    print "Enter your hourly rate: ";
    chomp(my $rate = <STDIN>);

(but that way of using chomp() isn't shown until the next chapter of
the book ... top of page 94). I may even line up the final group of
assignments depending on my mood:

    $otrate  = $overtime * $rate * 1.5;
    $regular = $regular  * $rate;
    $pay     = $regular  + $otrate;
 
As for style guidelines, The perlstyle manpage (as mentioned in
EPWP chapter 2) is a good source -- and you'll find that EPWP follows
those pretty closely (except I prefer cuddled elses in most cases).

regards,
andrew

-- 
Andrew L. Johnson   http://members.home.net/andrew-johnson/
      I drink to make other people interesting.
          -- George Jean Nathan


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

Date: Fri, 11 Aug 2000 12:00:32 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Best practices....
Message-Id: <39944D50.1BC90DC2@stomp.stomp.tokyo>

Lou Moran wrote:
 
> ...I am not a programmer, though I sometimes program things.

Yeah.. ok... * scratches her head *
 
> ...I read a fair amount of O'Reilly's but I used Elements of
> Programming with Perl to really get things going.

Reading and learning is excellent, not just for programming
but rather all notions of Life. I truly wish all people would
set aside daily time to read and learn. We would certainly have
less ignorant people around annoying us. Sad though, in many
situations, in many cultures, reading is beyond economic ability.

 
> Apparently my code is ugly.

Code which works and is relatively efficient is not ugly.
Don't fall into this Obsessive Techno-Geekster trap around
here which demands you write with Egyptian Hieroglyphics.
Code which is written in Plain English, easy to read, easy
to maintain, is pretty code! Stuff you see around here is
quite obscence, if not vulgar, to my eyes. Write your code
in whatever way pleases you. It is your code afterall.
Use whatever style suits your needs and personal taste.


> I would like to know where I can get a good best practices
> guide, lesson, clue....

Write lots and lots of programs from simple to complex,
from mundane to imaginative. This will teach you the
best of best methods. Sometimes you can find useful
code snippets around here. However, keep in mind,
most regulars here are not programmers. I have yet
to read any evidence anyone around here has ever
written a program. I am sure there are some programmers
in this group, but very few. 

A Language Lawyer Code Cop will bury you in mule manure.
Sort out who is a one liner weenie and who is a programmer.

Write lots of cgi programs, again simple to complex,
for use on our web. You will learn more about a little
bit of everything, if you will venture away from a
command line prompt. You will become a real programmer.
Never venturing out into the real world, will render
you a "home system wanna-be programmer."


> ...so that my code is less offensive.

Offensive code is Cargo Cult Perl 5 Copy and Paste.
Don't copy and paste; your code won't be offensive.
How much will you learn about programming by becoming
talented at working a mouse?

Avoid using modules whenever possible. Although there
are a handful certainly worth using, such as LWP, most
modules serve no purpose other than to bloat your script
and make a lazy programmer of you. Learn to write code
which has no need for modules. You will learn programming
this way rather than learn how to be great at copy and
paste techniques. Modules are fairly much Cargo Cult 
these days. Avoid them, at least till you learn how
to be a good programmer with no need for modules.
Once you have learned how to program what modules do,
you will be in a better position to assess when you
need to use a module and, when you don't.


> When I am in NT I use UltraEdit to write in, and Xemacs
> when I am in Linux (although I just got Xemacs for NT so
> I might switch)

Ok. Everyone has their own favorite program editor.

 
> Here is an example:  (I didn't comment anything b/c even
> I can figure out what it means) 
>(this was a lesson from EoPwP)


You are not clear here if you wrote this code or
if you copied this from a book. Clarity in writing
is very critical for effective communication.

So play with this code, break it, fix it, change it,
make it do stuff it ain't suppose to do! This is how
you truly learn after learning some basics via books.
However, don't misunderstand. Use your books, always
and always. Reference sources are invaluable.

 
> #!/usr/bin/perl -w
> use strict;

Ha! Use of -w warnings and use of 'use strict' is
an oxymoron for this code. Pragma hints, warnings,
strict, taint and so forth, slow down your script
and bloat your memory use for no benefit.

A clear sign of a person who knows diddly squat
about programming is a person who proclaims you
must always use pragma hints and another clear
sign of a non-programmer is a person who leaves
in pragma hints when they are no longer needed.

DUH!

Pragma hints are very helpful and serve a good
purpose if you know how to use them correctly.
Very few around here know how to use pragma
hints correctly. Be cautious.

Use pragma hints only during development of
scripts which are moderately long or moderately
complex or more so in both cases. 

This example script you display, use of -w
and 'use strict' is a proclamation by the
programmer,

"I don't know diddly squat about programming."

(Sorry if you wrote this code, but this is realistic.)

There is zero need for pragma hints within a
script this simple. Chances are good pragma
hints for a simple script like this will cause
more problems than resolved.

For a brandy new real fresh beginner, I would
claim an exception and say, "Use pragma hints
until you no longer need them. Then never ever
use them again, unless truly needed."

Pragma hints will turn you into a lousy programmer.
You will never learn how to resolve really tricky
problems in programming. Pragma hints will not
allow you to experiment, not allow you to be
creative and imaginative.

Pragma hints are training wheels. Use them until
you learn, taking a fall hurts. Then toss those
training wheels and start learning the best
of lessons; hard lessons.

Last word on pragma hints. They are useful, they
serve a good purpose. Nevertheless, pragma hints
are well noted for returning error messages which,
in themselves, are in error. Additonally, most
messages from pragma hints are gibberish. Read up
on pragma hints, what they mean, so you won't be
misled by gibberish or, in error pragma hints.

 
> my ($rate, $otrate, $regular, $overtime, $pay);

Pretty! Neat and clean. Use of 'my' is not needed
for a tiny learning script like this. Doesn't hurt
to use my, but doesn't benefit you either. Good
practice though to release memory back to perl
once my variables are used up and gone. Do use
'my' for regular scripts, especially larger
scripts. Use of 'my' lends efficiency by returning
memory blocks to perl core.

You will be a better programmer if you learn how
to use, 'global', 'local' and 'my' type variables.
Each has its own critical importance. There are
many here who will tell you to always use 'my'
and only 'my', at all times. These are people
who are not programmers. Flip 'em off and move
on with your learning.

(snipped)

Rest of this example code from a book, you will
learn best by playing with it, by breaking it
and fixing it. This code, it is an excellent
example for starting out or, if you personally
wrote this code, it is a job very well done
for starting out. However, it has some very 
serious problems. A quick example you ask? 
For your hourly rate, $rate, enter,

"Seven dollars and fifty cents per hour."

at your command line prompt and watch what happens.
Still, this is a notion you will learn about later
during your course of study.


Interesting writing style you have. Idioms in
writing are always unavoidable. Nevertheless
I find enjoyment in writing simple articles
like this and, enjoyment in causing boys to
toss Hissy Fits by giving them a loving
spoonful dose of bitter reality. Mothers
and English teachers are ornery like this.
I am quite ornery, being both.

Godzilla!


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

Date: Fri, 11 Aug 2000 15:12:06 -0400
From: Lou Moran <lmoran@wtsg.com>
Subject: Re: Best practices....
Message-Id: <4E6UORWG8EAPbJNtDmdmsVvzRlwk@4ax.com>

Hey you wrote the book...  Just so you know this very NG has ripped my
style to shreds and I suppose it's your style!

Great book BTW very useful as a stepping stone to Perl for System
Administration...

On Fri, 11 Aug 2000 18:35:51 GMT, andrew-johnson@home.com (Andrew
Johnson) wrote:

>In article <6yqUOdNhqAAHDDxoguXX6WOM90lZ@4ax.com>,
> Lou Moran <lmoran@wtsg.com> wrote:
>
>[snip]
>
>! Apparently my code is ugly.  I would like to know where I can get a
>! good best practices guide, lesson, clue, so that my code is less
>! offensive.
>
>Who says it's ugly? Lemme at 'em, lemme at 'em!
>
>Seriously, I've looked at the example you included and it is not
>substantially different from the solution I provide for that
>exercise.
>
>I generally do not put newlines at the end of my prompt-strings, and
>I'd likely declare the variables as needed rather than all at the
>top. I'd also combine the chomp() and input assignment in the same
>statement:
>
>    print "Enter your hourly rate: ";
>    chomp(my $rate = <STDIN>);
>
>(but that way of using chomp() isn't shown until the next chapter of
>the book ... top of page 94). I may even line up the final group of
>assignments depending on my mood:
>
>    $otrate  = $overtime * $rate * 1.5;
>    $regular = $regular  * $rate;
>    $pay     = $regular  + $otrate;
> 
>As for style guidelines, The perlstyle manpage (as mentioned in
>EPWP chapter 2) is a good source -- and you'll find that EPWP follows
>those pretty closely (except I prefer cuddled elses in most cases).
>
>regards,
>andrew


 ...no Y2K was fine, it was W2K we had the problems with...
lmoran@wtsg.com


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

Date: Fri, 11 Aug 2000 12:43:36 -0700
From: "Lauren Smith" <lauren_smith13@hotmail.com>
Subject: Re: Best practices....
Message-Id: <8n1ku3$i97$1@brokaw.wa.com>

De-Jeopardization not performed.

Lou Moran <lmoran@wtsg.com> wrote in message
news:4E6UORWG8EAPbJNtDmdmsVvzRlwk@4ax.com...
> Hey you wrote the book...  Just so you know this very NG has ripped my
> style to shreds and I suppose it's your style!
>
> Great book BTW very useful as a stepping stone to Perl for System
> Administration...
>

> On Fri, 11 Aug 2000 18:35:51 GMT, andrew-johnson@home.com (Andrew
> Johnson) wrote:
<snip>

Lou, sounds like you're doing great with Perl.  Now follow this link to
learn more about posting here:
http://x51.deja.com/getdoc.xp?AN=548402582&CONTEXT=966022653.271581221&hitnu
m=13

Lauren
--
print grep ord $_,map{y/a-z//d;$x.="+ $_";chr(eval $x)}
'J74u43-s2tA1-84n33o45th1er5-12-P3e13-82r48l21H13-a6-76
c40k25er2wx8-y6z13-81'=~m#([^!\n]{3})#g#tr/-0-9//d;print





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

Date: Fri, 11 Aug 2000 16:06:06 -0400
From: Lou Moran <lmoran@wtsg.com>
Subject: Re: Best practices....
Message-Id: <l1qUOSo+3mCr3nbjtRDxHiSSudIX@4ax.com>

On Fri, 11 Aug 2000 12:00:32 -0700, "Godzilla!"
<godzilla@stomp.stomp.tokyo> wrote:

>Lou Moran wrote:
> 
>> ...I am not a programmer, though I sometimes program things.
>
[Snipped, but read]

>Avoid using modules whenever possible. Although there
>are a handful certainly worth using, such as LWP, 

d'oh!  modules are one of the reasons I like Perl!

>You are not clear here if you wrote this code or
>if you copied this from a book.

It was a challenge quesion... I wrote the code.

>> #!/usr/bin/perl -w
>> use strict;

I thought I was supposed to use the -w and use strict; 

There is more than one way to do it, I suppose

>Mothers and English teachers are ornery like this.
>I am quite ornery, being both.

I'm a Dad with an English Degree (History too, dbl major) and I am
plenty ornery in the Lotus Notes NG ;)

Thanks BTW,

Your post was very helpful... Although having the author of the book I
was using, answer in this NG just made my CIO agree to allow me to use
Perl for an upcoming project... Maybe if you were Monster Zero he'd
have been even more impressed!   

>
>Godzilla!


 ...no Y2K was fine, it was W2K we had the problems with...
lmoran@wtsg.com


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

Date: Fri, 11 Aug 2000 20:11:53 GMT
From: andrew-johnson@home.com (Andrew Johnson)
Subject: Re: Best practices....
Message-Id: <d6Zk5.22331$k5.225001@news1.rdc1.mb.home.com>

In article <4E6UORWG8EAPbJNtDmdmsVvzRlwk@4ax.com>,
 Lou Moran <lmoran@wtsg.com> wrote:
! Hey you wrote the book...  Just so you know this very NG has ripped
! my style to shreds and I suppose it's your style!

Hmm, I just searched deja and I didn't find any threads ripping your
code style to shreds in this group -- perhaps I'm overlooking a
thread somewhere. 

At any rate, as with anything else, people have differing opinions
and preferences. Another poster, in this very thread, obviously has
ideas and suggestions that are rather contrary to my own practices
and recommendations (and those of many other's as well) ... even to
the point of implying that perhaps I know 'diddly squat' about
programming. You'll have to sort out what advice and which practices
make the most sense to you.

regards,
andrew

-- 
Andrew L. Johnson   http://members.home.net/perl-epwp/
      Where the hell are my fries, kid?
          -- Tom Christiansen, on comp.lang.perl.misc


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

Date: Fri, 11 Aug 2000 16:08:33 -0400
From: Drew Simonis <care227@attglobal.net>
Subject: Re: Best practices....
Message-Id: <39945D41.8E8FCFAB@attglobal.net>

[Posted and Cc'd]

Lou Moran wrote:
> 
> On Fri, 11 Aug 2000 12:00:32 -0700, "Godzilla!"
> <godzilla@stomp.stomp.tokyo> wrote:
> 
> >Lou Moran wrote:
> >
> >> ...I am not a programmer, though I sometimes program things.
> >
> [Snipped, but read]

Lou,
Godzilla! is our local and un-loveable troll.  S/he delights in 
giving out bad advice and generally making an ass of her/himself.

If you are not familiar with the term troll, read up here:

http://www.jargonfile.org/jargon/html/entry/troll.html


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

Date: Fri, 11 Aug 2000 14:30:19 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Best practices....
Message-Id: <3994706B.A8144936@stomp.stomp.tokyo>

Lou Moran wrote:
 
> Godzilla! wrote:
> >Lou Moran wrote:

(snipped) 

> Maybe if you were Monster Zero he'd have been even more impressed!



"Reality is a harsh mistress few will bed."

 - Kira

It is my experience very few, especially the male
of our species, are willing to deal with reality.
Living a fantasy is easier but rarely rewarding.

My realistic practical attitude leads many here
and elsewhere to regard me with contempt if not
outright hatred. I tend to burst fantasy bubbles
with a pin prick of reality. 

I find reality, along with my realistic minded
life long boyfriend, to be the best of lovers. 
We do things almost all others are too fearful 
to do, like lead a full and productive life, 
albeit hard work at times.

Godzilla!

--
Life's Been Good. I will rock you.
  http://la.znet.com/~callgirl3/lifegood.mid


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

Date: Fri, 11 Aug 2000 14:53:51 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Best practices....
Message-Id: <399475EF.F9E6D1F9@stomp.stomp.tokyo>

Andrew Johnson wrote:

>  Lou Moran <lmoran@wtsg.com> wrote:

> At any rate, as with anything else, people have differing opinions
> and preferences. Another poster, in this very thread, obviously has
> ideas and suggestions that are rather contrary to my own practices
> and recommendations (and those of many other's as well) ... even to
> the point of implying that perhaps I know 'diddly squat' about
> programming. You'll have to sort out what advice and which practices
> make the most sense to you.



Reality is a cutthroat bitch just like me. She and myself
get along quite well, very well indeed.

As a well published authoress, I will comment, for a 
published author, your reading comprehension skills
are diddly squat and your stereotypical fragile male
ego is quite laughable.

Consider yourself lucky I didn't write a review
of your writing skills. My policy is usually one
of "hands off" when it comes to technical writers;
they don't know how to write nor are trained how
to write effectively and efficiently with expertism.

Realistic advice is rarely welcomed advice.

Godzilla!


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

Date: Fri, 11 Aug 2000 21:49:31 GMT
From: Steven Merritt <smerr612@mailandnews.com>
Subject: Re: Best practices....
Message-Id: <8n1sda$944$1@nnrp1.deja.com>

In article <l1qUOSo+3mCr3nbjtRDxHiSSudIX@4ax.com>,
  Lou Moran <lmoran@wtsg.com> wrote:
> On Fri, 11 Aug 2000 12:00:32 -0700, "Godzilla!"

> Your post was very helpful... Although having the author of the book I
> was using, answer in this NG just made my CIO agree to allow me to use
> Perl for an upcoming project... Maybe if you were Monster Zero he'd
> have been even more impressed!

YHBT, YHL, HTH, HAND.

Steven
--
King of Casual Play
The One and Only Defender of Cards That Blow
www.jargonfile.org


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Fri, 11 Aug 2000 15:08:08 -0500
From: Brian <mail@mail.com>
Subject: can't read file handle
Message-Id: <39945D28.DE2D0093@mail.com>


When I step through the following snippet it skips the entire while
loop.  However if, when I open it, I take out the input symbol by
rec.txt it moves through the while loop.  (and of course can't print to
REC).  Anybody ever had a problem like this before?

open( REC, ">rec.txt" ) || die "Can't open rec.txt";
while(<REC>) {
    chomp;
 if( $theLine eq $_ ) {
  $_= join "", $_, $comment;
  print REC $_;
 }
}
close REC;



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

Date: Fri, 11 Aug 2000 16:18:44 -0400
From: Drew Simonis <care227@attglobal.net>
Subject: Re: can't read file handle
Message-Id: <39945FA4.984057BD@attglobal.net>

Brian wrote:
> 
> When I step through the following snippet it skips the entire while
> loop.  However if, when I open it, I take out the input symbol by
> rec.txt it moves through the while loop.  (and of course can't print to
> REC).  Anybody ever had a problem like this before?

You need to re-read the documentation for the <> thingie.  
When you open a file for writing, it is empty.  <> returns 
true until EOF.  In this case, it is never true because the 
file starts off empty.  <> is used when reading from a file,
not writing to one. (as the documentation for open() clearly 
indicates, you can open a file read/write, in which case the 
<> thingie will work)

> 
> open( REC, ">rec.txt" ) || die "Can't open rec.txt";
> while(<REC>) {
>     chomp;
>  if( $theLine eq $_ ) {
>   $_= join "", $_, $comment;
>   print REC $_;
>  }
> }
> close REC;

Looks like you want to read and write to a file at the same time.  
Read this documentation:

http://www.perl.com/pub/doc/manual/html/pod/perlfunc/open.html


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

Date: 11 Aug 2000 20:36:08 GMT
From: Erik van Roode <newsposter@cthulhu.demon.nl>
Subject: Re: can't read file handle
Message-Id: <8n1o3o$jkv$1@internal-news.uu.net>

Brian <mail@mail.com> wrote:

> When I step through the following snippet it skips the entire while
> loop.  However if, when I open it, I take out the input symbol by
> rec.txt it moves through the while loop.  (and of course can't print to
> REC).  Anybody ever had a problem like this before?

> open( REC, ">rec.txt" ) || die "Can't open rec.txt";
> while(<REC>) {
>     chomp;
>  if( $theLine eq $_ ) {
>   $_= join "", $_, $comment;
>   print REC $_;
>  }
> }
> close REC;

  Well, if you open a file for reading, you can't write to it, and if
you open a file for writing, you can't read from it. So if you want to
read _and_ write, you should open it for read _and_ write. But that
probably would not be a good solution in this case.

  Open your input file for reading, open a temporary file for writing.
Read from the former, write to the latter. After processing all input
you rename the output file to the input file. Add locking/closing where
appropriate.

Erik



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

Date: Fri, 11 Aug 2000 21:13:07 +0200
From: "Dominique PLU" <dominique.plu@ifrance.com>
Subject: Re: CGI, How to get back to cached dokument
Message-Id: <8n1ipm$j8v$1@reda.worldonline.fr>

Hello,

This is not a joke for for each my cgi file, I use a validation sub
procedure before processing and after ( if I detect an error) I recommand
with a message that the user click on previous on the navigator but I think
you can add something like  javascript:back() to force the navigator.

Also you can but it's very long use hidden field for assuming before
recalling your primal form that the default of field is the param passed to
the procedure
So at the first call , all field are blank and if you recall the CGI, it use
the parameters as default


Hope this will help you

Dominique PLU
Production Support
SCT International
France


Bulent Sarinc <Bulent@khio.no> a écrit dans le message :
39942837.B6CAEC7A@khio.no...
> Hi,
>
> A trivial question for experienced CGI programmers
>
>
> CGI, How to get back to cached already-filled-form from a CGIscript
> without erasing the text in the fields.?
>
> I use perl as programming language.
>
> Thanx in advance
>
> Bulent@khio.no
>




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

Date: Fri, 11 Aug 2000 20:02:49 GMT
From: Hermann <hermann@wecke.de>
Subject: Checking the IP and reverse
Message-Id: <8n1m56$4dj$1@nnrp1.deja.com>

I need to check if the DNS is being resolved from an IP range
(nslookup or mod-perl gethostbyname).

Have anyone here been involved with such task? I can't use a "normal"
windows-based program, as I will test more than 10k non-contiguous IPs,
and they may change from month to month... and every month I need to run
this script again...

My table looks like this:
10.1.1.0  (256)
10.1.10.0  (65)
[.... and several other lines below these 2]

The script should check if the reverse exists, and if the reverse is
resolving back to its original IP number.

First step: 10.10.10.1 -> port1.foo.com
Second step: port1.foo.com -> 10.10.10.1

I checked http://www.fuhr.org/~mfuhr/perldns/ and found a (maybe)
usefull script (mresolv2 at
http://www.fuhr.org/~mfuhr/perldns/mresolv2).

Any further references to look into?

Thanks,

Hermann


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: 11 Aug 2000 19:22:11 GMT
From: abigail@foad.org (Abigail)
Subject: Re: Converting from US dates/numbers to European dates/numbers
Message-Id: <slrn8p8ki5.cro.abigail@alexandra.foad.org>

Larry Rosler (lr@hpl.hp.com) wrote on MMDXXXV September MCMXCIII in
<URL:news:MPG.13fb390b9b4ef53798ac50@nntp.hpl.hp.com>:
%% 
%% As I said in another post, a decimal-point separator '.' is no less 
%% subject to syntactic ambiguity than a decimal-comma separator ','.  
%% String-concatenation operator as compared to expression separator.

Yeah, and in Perl 5.6, . is even more overloaded. 

    perl -wle "print 42.42.42.42"

prints quite different results on 5.6 and 5.005.



Abigail
-- 
print 74.117.115.116.32.97.110.111.116.104.101.114.
      32.80.101.114.108.32.72.97.99.107.101.114.10


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

Date: 11 Aug 2000 19:24:27 GMT
From: abigail@foad.org (Abigail)
Subject: Re: Converting from US dates/numbers to European dates/numbers
Message-Id: <slrn8p8kmd.cro.abigail@alexandra.foad.org>

Keith Calvert Ivey (kcivey@cpcug.org) wrote on MMDXXXVI September
MCMXCIII in <URL:news:3994fca5.3174966@news.newsguy.com>:
&& Larry Rosler <lr@hpl.hp.com> wrote:
&& 
&& >As I said in another post, a decimal-point separator '.' is no less 
&& >subject to syntactic ambiguity than a decimal-comma separator ','.  
&& >String-concatenation operator as compared to expression separator.
&& 
&& In Perl perhaps, but I was speaking more generally.  In ordinary
&& writing lists are generally separated by commas even in Europe.

Well, normal people separate list items by a comma *and a space*, while
there's no space inside numbers. As in: 1,234, 567,893.



Abigail
-- 
perl5.004 -wMMath::BigInt -e'$^V=Math::BigInt->new(qq]$^F$^W783$[$%9889$^F47]
 .qq]$|88768$^W596577669$%$^W5$^F3364$[$^W$^F$|838747$[8889739$%$|$^F673$%$^W]
 .qq]98$^F76777$=56]);$^U=substr($]=>$|=>5)*(q.25..($^W=@^V))=>do{print+chr$^V
%$^U;$^V/=$^U}while$^V!=$^W'


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

Date: Fri, 11 Aug 2000 14:08:39 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: Cross-platform shebang line CGI script shenanigans - Windows and  Linux with Apache
Message-Id: <39946B57.70FF951E@vpservices.com>

Doran wrote:
> 
> It shouldn't matter* what the shebang line reads on the Windows
> machine, particularly if it's running as a CGI script on a web server,
> since Windows handles all this through the registry. 

Nope, not in all cases.  Apache needs an accurate shebang line on
windoze as much as it does anywhere else, the registry is (properly)
ignored.

> All my scripts,
> whether they run on Windows or Linux begin with:
> 
> #!/usr/bin/perl -Tw

Mine too, (actually #!/usr/local/bin/perl -Tw) but that's because I
installed Active Perl in the c:\usr\local directory, not because I
depend on some M$ specific feature that M$ builds into their own
webservers.

-- 
Jeff


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

Date: Fri, 11 Aug 2000 20:45:53 GMT
From: doran@NOSPAMaltx.net (Doran)
Subject: Re: Cross-platform shebang line CGI script shenanigans - Windows and Linux with Apache
Message-Id: <39946449.16439312@news2.brandx.net>

On Tue, 8 Aug 2000 16:39:41 +0100, "Glyndwr"
<glynFOOdwr@FSCKdeleteEmeD.co.uk> wrote:

>I've been involved recently in efforts to move some websites from
>Debian/Apahce/Perl/MySQL to a Windows2000 laptop for demoing purposes.
>Everything works fine, but in order to make each CGI script work, the
>shebang line needs to be changed from
>
>#!/usr/bin/perl              [Linux]
>to
>#!c:/perl/bin/perl.exe    [Windows]
>
>Does anyone know of any way to write a single shebang line that works on
>both platforms? I'm thinking something with eval should work, but my poor
>brain isn't up to the task.. Thanks in advance.

I haven't installed Perl onto a W2K box yet, but the following is true
for all the dozens of Win9x and NT boxes I've worked with:

It shouldn't matter* what the shebang line reads on the Windows
machine, particularly if it's running as a CGI script on a web server,
since Windows handles all this through the registry. All my scripts,
whether they run on Windows or Linux begin with:

#!/usr/bin/perl -Tw

Are you sure your Perl is installed correctly on the Windows machine?
Also, what version of Perl on the Win-box? That also might make a
difference. My Win machines all have ActivePerl installed.

Good luck,
Doran...

*Windows does read the command-line options on the shebang line, so -T
or -w still makes a difference.





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

Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 16 Sep 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.  

| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

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 V9 Issue 3990
**************************************


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