[16851] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4263 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Sep 8 14:15:38 2000

Date: Fri, 8 Sep 2000 11:15:24 -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: <968436924-v9-i4263@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Fri, 8 Sep 2000     Volume: 9 Number: 4263

Today's topics:
    Re: use strict: why? <godzilla@stomp.stomp.tokyo>
    Re: use strict: why? <bkennedy99@home.com>
    Re: use strict: why? <godzilla@stomp.stomp.tokyo>
    Re: use strict: why? <godzilla@stomp.stomp.tokyo>
    Re: use strict: why? <jeffp@crusoe.net>
    Re: use strict: why? <godzilla@stomp.stomp.tokyo>
    Re: use strict: why? (Randal L. Schwartz)
    Re: use strict: why? <christopher_j@uswest.net>
    Re: use strict: why? (Tom Christiansen)
    Re: use strict: why? <bkennedy99@home.com>
    Re: use strict: why? <flavell@mail.cern.ch>
    Re: use strict: why? mexicanmeatballs@my-deja.com
    Re: use strict: why? (Tom Christiansen)
    Re: use strict: why? <godzilla@stomp.stomp.tokyo>
    Re: use strict: why? <godzilla@stomp.stomp.tokyo>
    Re: use strict: why? <godzilla@stomp.stomp.tokyo>
    Re: Using  localtime(time) Function <19wlr@globalnet.co.uk>
    Re: Using  localtime(time) Function <19wlr@globalnet.co.uk>
    Re: Variable not accepting value nobull@mail.com
    Re: website (Tony L. Svanstrom)
    Re: website <jpryan@labs.tamu.edu>
    Re: website (Abigail)
        xml parsing <jaap@stack.nl>
    Re: xml parsing (Abigail)
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Fri, 08 Sep 2000 08:09:39 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: use strict: why?
Message-Id: <39B90133.1D698EBF@stomp.stomp.tokyo>

Bart Lateur wrote:
 
> Godzilla! wrote:
 
> >> Variables that have been local()'ized are still global variables,

> >Nope! They are local variables. Global variables remain
> >the same. Local variables can be changed at whim and wish,
> >locally. Since when does local mean global?
 
> They are global. Only: the value adssigned to it is temporary. Once you
> leave the block where the variable is localized, the old value is
> restored.
 
>         $x = "global";
>         &test;
>         {
>            local $x = "local";
>            &test;
>         }
>         &test;
> 
>         sub test {
>             print "The value of the variable \$x is \"$x\"\n";
>         }
> -->
>         The value of the variable $x is "global"
>         The value of the variable $x is "local"
>         The value of the variable $x is "global"
 
> In summary: it's the same variable. Therefore, it is a global variable.



Excuse me? * laughs *

Do you realize how oxymoronic is your statement?

Godzilla!
-- 
Gypsy Wildrose Pawnee - Fortune Teller
  http://la.znet.com/~callgirl/fortune.cgi


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

Date: Fri, 08 Sep 2000 15:20:19 GMT
From: "Ben Kennedy" <bkennedy99@home.com>
Subject: Re: use strict: why?
Message-Id: <Ts7u5.15988$AW2.204280@news1.rdc2.pa.home.com>


"Godzilla!" <godzilla@stomp.stomp.tokyo> wrote in message
news:39B8BB4C.E3C24262@stomp.stomp.tokyo...
> Ben Kennedy wrote:
>
> > "Godzilla!" wrote:
>
> > Variables that have been local()'ized are still global variables,
>
> Nope! They are local variables. Global variables remain
> the same. Local variables can be changed at whim and wish,
> locally. Since when does local mean global?

local() should have been named "temporarily save current value" - its
original intent was to privatize variables by saving the current value and
restoring it later.  However, it is an imperfect solution because it does
not create a new variable.  It has the effect of privitization, but its not
as complete as my(),

> > perl temporarily stores the old value, and restores it when the block
ends.
>
> Are you sure this is what happens? Maybe a new variable
> is created without any change to the global.
>
> local = global
> local = whatever you do to it
> exit block .. local = gone!

The new value takes the place of the old one in the symbol table for the
duration of the block

> > 'my' variables are faster because the are created from scratch
> > and stored in a truly local space, and there is no overhead for
> > saving and restoring another value.
>
> MULE MANURE! Use of my declarations invokes all kinds
> of added processing for perl core, especially in
> conjunction with strict. Globals sit up there like
> a teacher's scribblings on a chalk board for all to
> see. My declarations are students scribbling away
> on their notebook paper, each and everyone, hopefully.
> Lots of pencil pushing going on with my declarations.

That is the main problem with globals - they are visible everywhere in the
program, when there is no need for them to be.  For varianbles in
subroutines, why expose all your scratch variables?  Furthurmore, once you
use them, the scriblings remain on the chalkboard.  This makes things
cluttered.   As for the speed, someone elsed posted a convincing benchmark
that my variables are faster to create than it is to local()'ize a global
varible, hence less work for the perl core.

> > Code written with a generous amount of 'my's tends to be
> > more self-contained, and is easier to integrate with
> > other programs.
>
> More mule manure! My declarations are a pain. A programmer
> has to be very careful when and where to use them. Use
> of my declarations, incorrectly, can crash a program
> quicker than you can flick a booger.
>
> Easier to integrate? You are nuts! Go on. Declare your
> routine output a my variable, then try to incorporate
> this routine into another larger program and see what
> happens! BLANK! Nothing happens. You have to back up
> and change your enclosed routine output to local or
> global or declare your output as a 'my global', then
> curse like crazy cause pragma hints crap all over!

This is what return statements are for -

sub my_func {
    my(@parameters) = @_;
    my $results;         # lexical

    # do some processing to $results

    return $results;
}

my $data = my_func('some', 'parameters');

And $data is equal to the lexical $results in the sub.  The results of the
my variable have been passed by value.  Now suppose you had declared
$results with local() - then Perl would have stored the value of $results
away, but $results would still be global.  Now if in your processing the
value of $results gets modified without someone local()'izing it, then you
may be in trouble.  This is because, as said before, local()'ized variables
are still global - that is, they can be manipulated by subroutines.  my()
variables on the other hand cannot be altered by a subroutine.

func_1();

sub func_1 {
    my $tmp = 4;
    func_2();
    print "Tmp = $tmp\n";
}

sub func_2 {
    my $tmp = 6;
    print "Tmp = $tmp\n";
}

this is exactly the behavior you should expect from private variables - each
scratchpad is independent.  Using local() variables definitely works, but is
more error prone:

func_3();

sub func_3 {
 local($tmp);
 $tmp = 6;
 func_4();
 print "== $tmp\n";
}

sub func_4 {
 $tmp = 2;
 print "== $tmp\n";
}

Now if you write all your code yourself, perhaps you can remember to
local()'ize all your variables.  If $tmp had been local()'ized in func_4,
you wouldn't get this odd behavior.  But what if you didn't write func_4()?
It could be someone elses legacy code.  If you are dealing with legacy code
that does who knows with with global variables, it is best to declare your
variables with my() - this 100% guarantees that there will be no
unpredictible side effects.  With local, you are taking your chances.
Considering that a large percentage of posters here are on a project team or
handling legacy code, advising people to use my() for their privitizaion
needs seems like a good idea to me.

--Ben Kennedy






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

Date: Fri, 08 Sep 2000 08:23:40 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: use strict: why?
Message-Id: <39B9047C.AC754588@stomp.stomp.tokyo>

mexicanmeatballs@my-deja.com wrote:
> 
> In article <39B8BB4C.E3C24262@stomp.stomp.tokyo>,
>   "Godzilla!" <godzilla@stomp.stomp.tokyo> wrote:
> > Ben Kennedy wrote:
> >
> 
> <snip>
> 
> > > 'my' variables are faster because the are created from scratch
> > > and stored in a truly local space, and there is no overhead for
> > > saving and restoring another value.
> >
> > MULE MANURE! Use of my declarations invokes all kinds
> > of added processing for perl core, especially in
> > conjunction with strict. Globals sit up there like
> > a teacher's scribblings on a chalk board for all to
> > see. My declarations are students scribbling away
> > on their notebook paper, each and everyone, hopefully.
> > Lots of pencil pushing going on with my declarations.
> 
> [jbarker@ninetyseven test]$ cat ./bench.pl
> #!/usr/bin/perl -w
> use Benchmark;
> timethese(1000000,




> Looks like my takes 72% of the time that local does. It probably
> depends on what you do with your variables though, if you declare
> them and increment them then local is slower.


Hello what? I read no use of a global variable for either
your my variable nor your local variable. Why would you
use local without a global, except for rare very exacting
circumstances? Discussion is about global variables and
speed related to my declarations, local declarations and
an overall relationship between a tradeoff between memory
and speed. Why no global manipulation? Your results are
rather invalid. Your results do not reflect true conditions
of an average script employing local declarations.


* laughs * 

I find it rather odd, Ben Kennedy, to read you posting
as Meatballs in defense of your prior statements. Because
of your clear deception, I am dismissing your results as 
deceptive as well. Why do you even bother trying to pull 
stunts like this with me, short of egomania, man/woman 
of a thousand ugly mugs?



Godzilla!
-- 
Gypsy Wildrose Pawnee - Fortune Teller
  http://la.znet.com/~callgirl/fortune.cgi


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

Date: Fri, 08 Sep 2000 08:31:08 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: use strict: why?
Message-Id: <39B9063C.AC6FCFBE@stomp.stomp.tokyo>

Ben Kennedy wrote:
 
> "Godzilla!" <godzilla@stomp.stomp.tokyo> wrote in message
> news:39B8BB4C.E3C24262@stomp.stomp.tokyo...
> > Ben Kennedy wrote:
> > > "Godzilla!" wrote:


(snipped)


Why do you even bother to try this type of mule manure
with me, of all people? Do you, man/woman of a thousand
ugly mugs, take me to be just another one of the ever
so gullible fools populating this group?

There is no way you can ever hide your idioms in writing
from me nor a way you will ever pull the wool over my
eyes with your slippery semantics mule manure.

*laughs*

Godzilla!
-- 
Gypsy Wildrose Pawnee - Fortune Teller
  http://la.znet.com/~callgirl/fortune.cgi


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

Date: Fri, 8 Sep 2000 11:33:34 -0400
From: Jeff Pinyan <jeffp@crusoe.net>
Subject: Re: use strict: why?
Message-Id: <Pine.GSO.4.21.0009081129090.23350-100000@crusoe.crusoe.net>

On Sep 8, Godzilla! said:

>> In summary: it's the same variable. Therefore, it is a global variable.
>
>Do you realize how oxymoronic is your statement?

The interesting thing to note is that local()ized variables exist in the
symbol table.  my() variables do not.  The meaning of 'global' is that it
is visible from anywhere in the program, and from other scopes as
well.  For example, I can say:

  require Socket;

and modify $Socket::CRLF because it's global, and not a my() variable.

As for efficiency/speed, local() is slightly slower because it has to save
away the value of the previously existing global variable (if any),
whereas my() just creates a new variable independent of... anything else,
really.

-- 
Jeff "japhy" Pinyan     japhy@pobox.com     http://www.pobox.com/~japhy/
PerlMonth - An Online Perl Magazine            http://www.perlmonth.com/
The Perl Archive - Articles, Forums, etc.    http://www.perlarchive.com/
CPAN - #1 Perl Resource  (my id:  PINYAN)        http://search.cpan.org/



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

Date: Fri, 08 Sep 2000 08:57:24 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: use strict: why?
Message-Id: <39B90C64.39D514F3@stomp.stomp.tokyo>

Jeff Pinyan wrote:
 
> Godzilla! wrote:
 
> >> In summary: it's the same variable. Therefore, it is a global variable.

> >Do you realize how oxymoronic is your statement?
 
> The interesting thing to note is that local()ized variables exist in the
> symbol table.  my() variables do not.  The meaning of 'global' is that it
> is visible from anywhere in the program, and from other scopes as
> well.  For example, I can say:
 
(snipped)
 
> As for efficiency/speed, local() is slightly slower because it has to save
> away the value of the previously existing global variable (if any),
> whereas my() just creates a new variable independent of... anything else,
> really.


Ok, your thoughts do make sense. Claiming a local variable
is a global variable as this other person did, certainly does
not make a lick of sense.

Nonetheless, global, local and my variables have specific
uses depending on circumstances; each type is important.
However, what I have indicated is use of globals and locals
can perform magic quicker and more efficiently than using
my declarations ever can, when used wisely. True basic
point is, these people around here who promulgate you
must use my declarations, always, are full of good 'ol
mule manure as sound logic dictates.

Consider structuring of a script. A need exists for
a global variable or variables as I stated previously,
along with indicating many sub-routines using a global
value for local manipulation. 

Which is quicker and more efficient? Using globals and
locals under these circumstances or using strictly all
my declarations to deal with global values? As you state,
my does not retain a global value with a benefit of
releasing memory. How do you go about manipulating a
my type global value with my declarations only, without
adding a lot of coding, thus less efficieny and slower
script speed and, perhaps greater memory usage overall
compared to use of global/local variables?


Your thoughts within this article are good, make sense
and could not be critique. However, I have made a note
you boys are moving away from the true topic I have
presented. This is to beg the issue. Most illogical.


Godzilla!
-- 
Gypsy Wildrose Pawnee - Fortune Teller
  http://la.znet.com/~callgirl/fortune.cgi


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

Date: 08 Sep 2000 09:11:23 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: use strict: why?
Message-Id: <m1g0na7tjo.fsf@halfdome.holdit.com>

>>>>> "Godzilla!" == Godzilla!  <godzilla@stomp.stomp.tokyo> writes:

Godzilla!> Ok, your thoughts do make sense. Claiming a local variable
Godzilla!> is a global variable as this other person did, certainly does
Godzilla!> not make a lick of sense.

No such claim was made.  A local()ized variable is not a "local"
variable, and Larry himself has expressed regrets about the choice of
name for the operator.  A local()ized variable is a global (also
called "package") variable that has a distinct temporary value.  Only
my() creates *true* local variables, ones that cannot be seen outside
their defining scope.

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!


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

Date: Fri, 8 Sep 2000 09:11:30 -0700
From: "Christopher M. Jones" <christopher_j@uswest.net>
Subject: Re: use strict: why?
Message-Id: <Mc8u5.537$QB6.113799@news.uswest.net>


"Godzilla!" <godzilla@stomp.stomp.tokyo> wrote:
> Ok, your thoughts do make sense. Claiming a local variable
> is a global variable as this other person did, certainly does
> not make a lick of sense.

They are exactly the same as global variables, the only
difference is that the value will change once executation
exits the block the local variable was declared in (to
the value of the local/global variable in the "parent"
block).

> Nonetheless, global, local and my variables have specific
> uses depending on circumstances; each type is important.
> However, what I have indicated is use of globals and locals
> can perform magic quicker and more efficiently than using
> my declarations ever can, when used wisely. True basic
> point is, these people around here who promulgate you
> must use my declarations, always, are full of good 'ol
> mule manure as sound logic dictates.

my variables are very useful in many situations,
especially in object oriented programming and the
creation of modules.  local variables are a hack
that can be useful under certain circumstances but
are not as full-featured as my variables.

> Consider structuring of a script. A need exists for
> a global variable or variables as I stated previously,
> along with indicating many sub-routines using a global
> value for local manipulation.
>
> Which is quicker and more efficient? Using globals and
> locals under these circumstances or using strictly all
> my declarations to deal with global values? As you state,
> my does not retain a global value with a benefit of
> releasing memory. How do you go about manipulating a
> my type global value with my declarations only, without
> adding a lot of coding, thus less efficieny and slower
> script speed and, perhaps greater memory usage overall
> compared to use of global/local variables?

Global variables and my variables can co-exist you
know?





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

Date: 8 Sep 2000 10:18:55 -0700
From: tchrist@perl.com (Tom Christiansen)
Subject: Re: use strict: why?
Message-Id: <39b9116f@cs.colorado.edu>

In article <39B90C64.39D514F3@stomp.stomp.tokyo>,
Godzilla! <godzilla@stomp.stomp.tokyo> wrote:
>However, what I have indicated is use of globals and locals
>can perform magic quicker and more efficiently than using
>my declarations ever can, when used wisely. 

You are, quite simply, wrong about nearly everything you've said
in this thread.  And not just subtly wrong, but screamingly wrong.
For example, there is no such thing whatsoever as a "local declaration".
The compiler has virtually nothing to do with dynamics; the interpreter
does that.  Likewise, the interpreter has virtually nothing to do
with lexicals; the compiler does that.  I will not tire this group
with correcting each and every one of your raving delusions, as I
don't have all day and all night.

The stark reality boils down to the simple fact that there exist
but two kinds of variables in Perl: those with stab entries in the
package symbol tables and those with pad entries which are associated
with a block.  The terms "global" and "local" as used by traditional
programming languages are not generally reasonable to apply to Perl,
and as they are used by you, are warped even further from sensibility.
One may call them dynamics and lexicals if you want to, although
even these the language lawyers could nitpick if they were particularly
clever.

>Which is quicker and more efficient? Using globals and
>locals under these circumstances or using strictly all
>my declarations to deal with global values? As you state,
>my does not retain a global value with a benefit of
>releasing memory. How do you go about manipulating a
>my type global value with my declarations only, without
>adding a lot of coding, thus less efficieny and slower
>script speed and, perhaps greater memory usage overall
>compared to use of global/local variables?

Don't be such a loon.  Go read the actual Perl source code that
controls this.  Inspect the precise instructions needed to access
stab variables versus those needed for accessing pad variables.
Read the illguts doc, too, while you're at it.  You are spouting a
lot of inane mythmongering here.  On top of it all, you are promoting
utterly stupid, short-sighted, and slip-shod programming practices
that do nothing but *hurt* people if they follow your extremely
horrible advice to overuse globals.  

If you were my student, I'd flunk you.  If you were my employee,
I'd fire you.  You've got a lot to learn about programming.  

And Perl.

Ladies and gentlemen, I suggest that you add a new killfile entry.
After reading dozens of messages from this poster, it is clear that
they have nothing to offer you but radically incorrect statements
about Perl and self-defeating programming timebombs, all wrapped
up with tangled prose and acidic bile.  Considering that the more
respectable and knowledgement participants in this forum never
bother addressing the insanities and inanities, I presume they have
already long ago seen the wisdom in killfiling.

--tom

*PLONK*


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

Date: Fri, 08 Sep 2000 16:31:40 GMT
From: "Ben Kennedy" <bkennedy99@home.com>
Subject: Re: use strict: why?
Message-Id: <Mv8u5.16028$AW2.204613@news1.rdc2.pa.home.com>


"Godzilla!" <godzilla@stomp.stomp.tokyo> wrote in message
news:39B90C64.39D514F3@stomp.stomp.tokyo...
> Jeff Pinyan wrote:
>
> > Godzilla! wrote:
> > As for efficiency/speed, local() is slightly slower because it has to
save
> > away the value of the previously existing global variable (if any),
> > whereas my() just creates a new variable independent of... anything
else,
> > really.
>
> Ok, your thoughts do make sense. Claiming a local variable
> is a global variable as this other person did, certainly does
> not make a lick of sense.

I think you are seeing a light.  A global variable is defined by the fact
that it is in the symbol table, and thus is globally accessable to every
piece of code that has access to the symbol table (everywhere).  A my
variable is not in the symbol table, but rather in a dedicated scratchpad
which only that chunk of code can access.  local() only alters the value of
a global variable, the variable continues to be in the sybmol table and
globally accessable.

> Nonetheless, global, local and my variables have specific
> uses depending on circumstances; each type is important.
> However, what I have indicated is use of globals and locals
> can perform magic quicker and more efficiently than using
> my declarations ever can, when used wisely. True basic
> point is, these people around here who promulgate you
> must use my declarations, always, are full of good 'ol
> mule manure as sound logic dictates.

The general rule of thumb should be to use the functions the way they were
created for:

use my to create a local variable that will be accessed only by its block of
code
use local to temporarily store away the value of a global variable

For variables that are global by defualt (like $_) you have to use local to
get a private copy.  As for efficiency, the post of the person who you
accused of being me has a good benchmark test.

> Which is quicker and more efficient? Using globals and
> locals under these circumstances or using strictly all
> my declarations to deal with global values? As you state,
> my does not retain a global value with a benefit of
> releasing memory. How do you go about manipulating a
> my type global value with my declarations only, without
> adding a lot of coding, thus less efficieny and slower
> script speed and, perhaps greater memory usage overall
> compared to use of global/local variables?

To answer your question, a my variable declared before any subroutines can
be accessed in those subroutines, for instance

my $variable = 1;

inc();

print "Var is now $variable\n";

sub inc {
    $variable++;
}

This lexical variable is visible to all subroutines declared within its
block, and functions like a global variable, except that it is not in the
symbol table.  my() variables also persist through package declarations,
which is nice.  Globals definitely have a vital place, but most of the time
a lexical will do the trick more efficiently due to less symbol table
mucking.

--Ben Kennedy





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

Date: Fri, 8 Sep 2000 18:36:05 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: use strict: why?
Message-Id: <Pine.GHP.4.21.0009081827070.24353-100000@hpplus03.cern.ch>

On 8 Sep 2000, Tom Christiansen wrote:

(to a long-since-rumbled troll):

> You are, quite simply, wrong about nearly everything you've said
> in this thread. 

Trolls do that...

> And not just subtly wrong, but screamingly wrong.

Of course the better class of troll would not make _that_ mistake,
which is why the group spotted this one relatively early.  Although
some of the regulars still get suckered into responding - maybe in the
belief that it will help to avoid newcomers being misled.

[...]

> Ladies and gentlemen, I suggest that you add a new killfile entry.

With respect - you've been away from this group for too long.

> After reading dozens of messages from this poster, it is clear that
> they have nothing to offer you but radically incorrect statements
> about Perl and self-defeating programming timebombs, all wrapped
> up with tangled prose and acidic bile.  

Right.  And threats, too.

All the best, it's good to see you participating here.



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

Date: Fri, 08 Sep 2000 16:41:33 GMT
From: mexicanmeatballs@my-deja.com
Subject: Re: use strict: why?
Message-Id: <8pb4rp$244$1@nnrp1.deja.com>

In article <39B9047C.AC754588@stomp.stomp.tokyo>,
  "Godzilla!" <godzilla@stomp.stomp.tokyo> wrote:
> mexicanmeatballs@my-deja.com wrote:
> >
> > Looks like my takes 72% of the time that local does. It probably
> > depends on what you do with your variables though, if you declare
> > them and increment them then local is slower.
>
> Hello what? I read no use of a global variable for either
> your my variable nor your local variable. Why would you
> use local without a global, except for rare very exacting
> circumstances? Discussion is about global variables and
> speed related to my declarations, local declarations and
> an overall relationship between a tradeoff between memory
> and speed. Why no global manipulation? Your results are
> rather invalid. Your results do not reflect true conditions
> of an average script employing local declarations.

Sorry, I think I misunderstood your earlier post.
Can you post some code that demonstrates your point?

> * laughs *
>
> I find it rather odd, Ben Kennedy, to read you posting
> as Meatballs in defense of your prior statements. Because
> of your clear deception, I am dismissing your results as
> deceptive as well. Why do you even bother trying to pull
> stunts like this with me, short of egomania, man/woman
> of a thousand ugly mugs?

If you look in the headers you will see that I'm in the UK, and Mr
Kennedy appears to be in the US. Although I can't prove I'm not him.

--
Jon
perl -e 'print map {chr(ord($_)-3)} split //, "MrqEdunhuClqdph1frp";'


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


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

Date: 8 Sep 2000 10:52:43 -0700
From: tchrist@perl.com (Tom Christiansen)
Subject: Re: use strict: why?
Message-Id: <39b9195b@cs.colorado.edu>

In article <Mv8u5.16028$AW2.204613@news1.rdc2.pa.home.com>,
Ben Kennedy <bkennedy99@home.com> wrote:

>local() only alters the value of
>a global variable, the variable continues to be in the sybmol table and
>globally accessable.

Usually, that's true enough as it goes, but nevertheless represents--shall
we say--a "simplified" version of reality.

To see what I mean, please consider:

    use strict;
    use warnings;

    our          @word = qw/who knows what evil lurks in the heart of perl/;
    { 
        my       @word = qw/do you see what I see/;
        local    @word[2,-1] = ("know") x 2;
        print "\u@word?\n";
    }
    print     "\u@word?\n";

Just to give you a thing or three to think about. :-)

--tom


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

Date: Fri, 08 Sep 2000 10:31:25 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: use strict: why?
Message-Id: <39B9226D.9CEE755D@stomp.stomp.tokyo>

"Randal L. Schwartz" wrote:
 
> > Godzilla! wrote:
 
> Godzilla!> Ok, your thoughts do make sense. Claiming a local variable
> Godzilla!> is a global variable as this other person did, certainly does
> Godzilla!> not make a lick of sense.
 
> No such claim was made.

Ahem...

"In summary: it's the same variable. Therefore, it is a global variable."


> A local()ized variable is not a "local" variable, and Larry himself has 
> expressed regrets about the choice of name for the operator.

Personally, I believe 'local' is an excellent choice for this
function. This word, local, well defines in my mind what is
does; localizes a variable, even if only temporary.


> A local()ized variable is a global (also called "package") variable 
> that has a distinct temporary value.  Only my() creates *true* local
> variables, ones that cannot be seen outside their defining scope.

This clearly cannot be argued, Randal, and is a good addition to
this quickly becoming ridiculous discussion. Intelligent comments
like this, are appreciated, least by me.

My contention, which seems to becoming slowly twisted into something
it is not by others, is all three basic types of variables, global,
local and my, all are very important. Programmers should learn how
to use each wisely and appropriately. People in this group should
not be stating, paraphrased, "You should always use my variables."

I mused on this a bit, this "always must use my" notion so rampant
around here. In my mind, my logic is thus. A global declaration
creates a 'global table' if I may use this term. A local variable,
in turn, manipulates this global table. A my declaration creates
a 'local table' which is destroyed when no longer needed. Stands
to good reasoning, there will be speed differences, although slight.

However, a situation I presented is a script which needs global
variables having numerous sub routines using global data for
manipulation, obviously, locally to each sub routine. It is
logical to declare a global or globals for this type of script.

Further musing led me to this contrasting logic. If you have
this same script, a script with a need for global data and, 
try to use * only * my declarations, you end up doing a mimic
of a global table, with my type temporary tables. Otherwords,
you are creating and destroying my tables, one after another,
trying to mimic a global table. This would create a bottleneck
in your script for sub routines.

I considered a pictorial viewpoint of having a 'global my' outside
of sub routines. To get this global my inside a sub routine for
manipulation, you need or may need to create a new my variable
to transport this global into a sub routine. In this case of
a sub routine calling another sub routine from within or without,
a new my variable is needed to be created, or 'global my' declarations
need to be used to maintain a flow of global usage data.

In a final analysis, for a script with a need for global data
serving numerous sub routines, nested sub routines and the such,
you end up declaring a lot of my variables to maintain a flow
of global data throughout a script; a mimic of a global table.
So, you end up creating and destroying so many my tables, a true
bottleneck is created at certain points in a script; you use more
memory and sacrifice some speed, by constantly creating a number
of my tables and then destroying them, to maintain global data.

Expressed in another way, you use so many my declarations, you
end up using more memory than you would by use of global/local
style of variables, right from the get go; bottlenecks are made.

All three types of variables, global, local and my are very
important and of equal value. Each should be applied wisely
and appropriately for a script's needs. This adamant attitude
of, paraphrased, "You MUST ALWAYS use my declarations," is
pure mule manure and a person who promotes this notion, also
announces he is lacking in knowledge of good practices in
Perl programming.

Good programming practices strike a balance between speed,
memory usage and efficiency. These criteria are best met
by not only appropriate use of variable types, but also
by use of good sound objective programming logic, rather
than illogical subjective clique dogma.


As a side note Randal, I am still using and testing my
large programs without being nph-client styles. So far,
I am very pleased. I swear these scripts run faster.
However and ironically oxymoronic pertaining to this
thread, I have also been converting global and local
variables over to my type variables when and where 
possible, with serious effort. I have noticed some
speed improvement with my type variables, overall.
Thus, I cannot say with high confidence, an nph
client is slower than a regular everyday cgi;
results being skewed by us of my variables

In contrast, I have also noticed a degrading of
overall performance by trying to convert often
used global variables to my variables. So, as
I contend, my efforts are directed at finding
the best blend of global, local and my type
variables for my larger complex programs.


Godzilla!
--
@© = (a .. z); @® = qw (7 15 4 26 9 12 12 1 18 15 3 11 19);
srand(time() ^ ($$ + ($$ << 15))); for ($§ = $®[$®[0]]; $§ < $®[0]; $§++)
{ sub G { rand(1000) < 500 ? "\u$1" : "\l$1" ; } foreach $¿ (@®) 
{ $¢ = $©[$¿-1]; $¢ =~ s¡([a-z])¡G($1)¡gie; $Ø = "$Ø$¢"; }
$Ø ="$Ø! "; $ø = substr ($Ø, $®[12] - $®[11], 0, " ");
$Ø =~ s¯(a)(r)¯$1 $2¯i; push (@Ø,$Ø); } foreach $¡ (@Ø)
{ print "$¡\n"; } @¶ = reverse (@Ø); foreach $¶ (@¶)
{ print "$¶\n"; } exit;









-- 
Gypsy Wildrose Pawnee - Fortune Teller
  http://la.znet.com/~callgirl/fortune.cgi


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

Date: Fri, 08 Sep 2000 10:42:40 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: use strict: why?
Message-Id: <39B92510.ADFCDC8D@stomp.stomp.tokyo>

Tom Christiansen wrote:
 
> Godzilla! wrote:

Upon reading your first use of Ad Hominem,
I dismissed you as an intellectual subordinate.
You disgrace yourself with such petty and childish
behavior and, reveal your lack of self-confidence,
your ample ignorance of common communicative skills
and your ignorance of common reading comprehension
skills. Shameful, I say.


Godzilla!
-- 
Gypsy Wildrose Pawnee - Fortune Teller
  http://la.znet.com/~callgirl/fortune.cgi


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

Date: Fri, 08 Sep 2000 10:53:08 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: use strict: why?
Message-Id: <39B92784.3FD588FC@stomp.stomp.tokyo>

mexicanmeatballs@my-deja.com wrote:

>   Godzilla! wrote:
> > mexicanmeatballs@my-deja.com wrote:

(snippage)

> Sorry, I think I misunderstood your earlier post.
> Can you post some code that demonstrates your point?

Right. As if I would sucker for this troll bait.

 
> > * laughs *

* laughs again *


> > I find it rather odd, Ben Kennedy, to read you posting
> > as Meatballs in defense of your prior statements. Because
> > of your clear deception, I am dismissing your results as
> > deceptive as well. Why do you even bother trying to pull
> > stunts like this with me, short of egomania, man/woman
> > of a thousand ugly mugs?
 
> If you look in the headers you will see that I'm in the UK, and Mr
> Kennedy appears to be in the US. Although I can't prove I'm not him.

Nor can I easily prove you are him, without effort I am unwilling
to invest in such a worthless cause; people here are too foolish
to realize reality. I could careless what you do here, except when 
what you do involves me. These others, pffttt.. they deserve what
they get and, in the end, they are sure getting it from you.

If you would like, I can forge my headers to indicate
I am posting from Alturus 5, Gamma Sector. This type
of forgery is old hat. Give me a C class server with
a peer news feed service, I will have my headers
indicate I am posting from God's Throne up 
there in Her Heaven and everywhere else in
Her Creation. Old tricks for old fools.

My ego is healthy. I have no need to pretend to
be a thousand different people. I like myself.


Godzilla!
-- 
Gypsy Wildrose Pawnee - Fortune Teller
  http://la.znet.com/~callgirl/fortune.cgi


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

Date: Fri, 8 Sep 2000 17:42:19 +0100
From: "John Plaxton" <19wlr@globalnet.co.uk>
Subject: Re: Using  localtime(time) Function
Message-Id: <8pb524$ol3$1@gxsn.com>

Hi there can anyone spot the bug please

I'm trying to produce a string like:  8 Sept 2000 - 15 Sept 2000 (I'm
reading in 'time' from a flat file)

@months = qw(Jan Feb Mar Apr May June July Aug Sept Oct Nov Dec);

@today    = localtime(time);
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)=@today;
$year = ($year + 1900);
print "Today is $mday  $months[$mon] $year.\n\n";

This produces the correct date eg. 8 Sept 2000

@next_week= localtime(time + (7 * 86400));
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)=@next_week;
$year = ($year + 1900);
print "next week is $mday $months[$mon] $year.\n\n";

This produces the correct date eg. 15 Sept 2000


However, the next code produces 1 may 1970 - 8 May 1970

$datesstr = &createdatestr(time);
print" This is the doggy String   $datesstr\n\n";

sub createdatestr{
  @now = localtime($_);
  ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = @now;
  $year = ($year + 1900);
  $str = "$mday $months[$wday] $year - ";
  @next_week = localtime($_ + (7*86400));
  ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)= @next_week;
  $year = ($year + 1900);
  $str .= "$mday $months[$wday] $year";
  return ($str);
}

Where's the bug? Am I passing in the value of 'time' correctly or do dates
start from 1st May 1970?

If I keep on adding (7*86400) to 'time' do I keep on adding on I week, or is
the value of 'time' some strange incomprehensible beast?

Thanks in advance

john






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

Date: Fri, 8 Sep 2000 17:42:19 +0100
From: "John Plaxton" <19wlr@globalnet.co.uk>
Subject: Re: Using  localtime(time) Function
Message-Id: <8pb51j$okv$1@gxsn.com>

Hi there can anyone spot the bug please

I'm trying to produce a string like:  8 Sept 2000 - 15 Sept 2000 (I'm
reading in 'time' from a flat file)

@months = qw(Jan Feb Mar Apr May June July Aug Sept Oct Nov Dec);

@today    = localtime(time);
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)=@today;
$year = ($year + 1900);
print "Today is $mday  $months[$mon] $year.\n\n";

This produces the correct date eg. 8 Sept 2000

@next_week= localtime(time + (7 * 86400));
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)=@next_week;
$year = ($year + 1900);
print "next week is $mday $months[$mon] $year.\n\n";

This produces the correct date eg. 15 Sept 2000


However, the next code produces 1 may 1970 - 8 May 1970

$datesstr = &createdatestr(time);
print" This is the doggy String   $datesstr\n\n";

sub createdatestr{
  @now = localtime($_);
  ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = @now;
  $year = ($year + 1900);
  $str = "$mday $months[$wday] $year - ";
  @next_week = localtime($_ + (7*86400));
  ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)= @next_week;
  $year = ($year + 1900);
  $str .= "$mday $months[$wday] $year";
  return ($str);
}

Where's the bug? Am I passing in the value of 'time' correctly or do dates
start from 1st May 1970?

If I keep on adding (7*86400) to 'time' do I keep on adding on I week, or is
the value of 'time' some strange incomprehensible beast?

Thanks in advance

john






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

Date: 08 Sep 2000 17:23:52 +0100
From: nobull@mail.com
Subject: Re: Variable not accepting value
Message-Id: <u966o63l9j.fsf@wcl-l.bham.ac.uk>

<dwb1@home.com> writes:

> I'm having problems occasionally with variables not accepting a value.

Are they tied variables?

> The values of $in{QUESTION_PATH} is a string of numbers, seperiated by
> a ctrl-a character (for a web form).  The function is supposed to remove
> the last value in the string, and return the value it removed.  I'm sure
> this could be done a lot easier with a regular expression, but this is
> what I have right now :)

Yeah definitely:

sub RemoveLastQuestion {
  ($in{QUESTION_PATH} =~ s/\cA?([^\cA]*)$//)[0];
}

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: Fri, 8 Sep 2000 17:13:25 +0200
From: tony@svanstrom.com (Tony L. Svanstrom)
Subject: Re: website
Message-Id: <1egnh4u.1rbka1lnsa3c4N%tony@svanstrom.com>

James Ryan <jpryan@cis.tamu.edu> wrote:

> if anybody really cares, check out this web site that i wrote...  (its in
> perl of course)

Without looking at it I must say that I doubt it, because websites have
a tendency to be in HTML... 


     /Tony
-- 
     /\___/\ Who would you like to read your messages today? /\___/\
     \_@ @_/  Protect your privacy:  <http://www.pgpi.com/>  \_@ @_/
 --oOO-(_)-OOo---------------------------------------------oOO-(_)-OOo--
   on the verge of frenzy - i think my mask of sanity is about to slip
 ---ôôô---ôôô-----------------------------------------------ôôô---ôôô---
    \O/   \O/  ©99-00 <http://www.svanstrom.com/?ref=news>  \O/   \O/


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

Date: Fri, 08 Sep 2000 10:29:01 -0500
From: James Philip Ryan <jpryan@labs.tamu.edu>
Subject: Re: website
Message-Id: <39B905BD.678BBF61@labs.tamu.edu>

Haha, I _would_ agree with you but the ratio of Perl to html is about 1000
lines of Perl to 50 lines of HTML...  but technically you're right.

James Ryan

"Tony L. Svanstrom" wrote:

> James Ryan <jpryan@cis.tamu.edu> wrote:
>
> > if anybody really cares, check out this web site that i wrote...  (its in
> > perl of course)
>
> Without looking at it I must say that I doubt it, because websites have
> a tendency to be in HTML...
>
>      /Tony
> --
>      /\___/\ Who would you like to read your messages today? /\___/\
>      \_@ @_/  Protect your privacy:  <http://www.pgpi.com/>  \_@ @_/
>  --oOO-(_)-OOo---------------------------------------------oOO-(_)-OOo--
>    on the verge of frenzy - i think my mask of sanity is about to slip
>  ---ôôô---ôôô-----------------------------------------------ôôô---ôôô---
>     \O/   \O/  ©99-00 <http://www.svanstrom.com/?ref=news>  \O/   \O/



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

Date: 08 Sep 2000 16:45:46 GMT
From: abigail@foad.org (Abigail)
Subject: Re: website
Message-Id: <slrn8ri5rv.vlt.abigail@alexandra.foad.org>

James Ryan (jpryan@cis.tamu.edu) wrote on MMDLXV September MCMXCIII in
<URL:news:8paupi$4gt$1@news.tamu.edu>:
%% if anybody really cares, check out this web site that i wrote...  (its in
%% perl of course)
%% 
%% 
%% http://profpages.net


No it isn't.

    $ HEAD http://profpages.net
    200 OK
    Connection: close
    Date: Fri, 08 Sep 2000 16:39:34 GMT
    Server: Apache/1.3.4 (Unix) FrontPage/4.0.4.3 PHP/3.0.15
    Content-Type: text/html
    Client-Date: Fri, 08 Sep 2000 16:38:37 GMT
    Client-Peer: 63.249.167.131:80

    $

text/html would be the wrong content type for Perl.



                                     Welcome to The Profpages Network (p1 of 2)

   [INLINE]
   [INLINE]

                                  [INLINE]

                                  [INLINE]
                                 [1]______
                                  [INLINE]
                                 [2]______
                              [3][ ] No Expire

                             [4][IMAGE]-Submit

                                  [INLINE]
                                  [INLINE]

   [5]Sign Up!
   [6]Students
   [7]Professors
   [8]Corporate Info

                                  [INLINE]

   [INLINE] [9][LINK] [10][LINK] [11][LINK] [12][LINK] 


   Notice: We have been experiencing some network difficulties, we
   apologize if you were unable to create your account last night. The
   issue has been taken care of.

   [INLINE]
   [13][LINK] [14][LINK] 


     [INLINE]

   © Copyright 2000 [15]Vortech Development Inc.
   All information and services provided here are protected under our
   [16]disclaimer.



Wonderful! There are only 2354 billion other webpages full with [INLINE].
What an original concept!


Abigail
-- 
$_ = "\nrekcaH lreP rehtona tsuJ"; my $chop; $chop = sub {print chop; $chop};
$chop -> () -> () -> () -> () -> () -> () -> () -> () -> () -> () -> () -> ()
-> () -> () -> () -> () -> () -> () -> () -> () -> () -> () -> () -> () -> ()


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

Date: Fri, 08 Sep 2000 17:04:28 GMT
From: "Jaap" <jaap@stack.nl>
Subject: xml parsing
Message-Id: <w_8u5.168577$LX4.1427988@nlnews00.chello.com>

Hi,

XML parsers like XML::Parser are quite unsatisfying imho. So, i tried to do
it myself.

 ... some code to get the xml file in a single string ($xml), spaces removed
 ...

if ($xml =~ /<(.*?)>(.*?)<\/\1>/)
{ $xml{$1} = $2;
}

I want to make a nested hash  %xml that contains ALL the data. (nevermind
attributes at this time)
Example:
$xml{'parent'}->{'child'}->{'subchild'} = 'value';

PROBLEM:
I don't know how deep the xml goes, so there's no limit to the nesting...

How do i do this?
Thx in advance for ANY help.




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

Date: 08 Sep 2000 17:30:45 GMT
From: abigail@foad.org (Abigail)
Subject: Re: xml parsing
Message-Id: <slrn8ri8ga.vlt.abigail@alexandra.foad.org>

Jaap (jaap@stack.nl) wrote on MMDLXV September MCMXCIII in
<URL:news:w_8u5.168577$LX4.1427988@nlnews00.chello.com>:
// Hi,
// 
// XML parsers like XML::Parser are quite unsatisfying imho. So, i tried to do
// it myself.
// 
// ... some code to get the xml file in a single string ($xml), spaces removed
// ...
// 
// if ($xml =~ /<(.*?)>(.*?)<\/\1>/)
// { $xml{$1} = $2;
// }

That's of course an extrememly bad way of parsing xml. It doesn't deal
correctly with:

    <foo bar = ">">text</foo>
    <!-- <> -->
    <foo/>
    <[ CDATA [ <foo> ]]>
    <? flurp ?>
    <foo>text<foo>text</foo>text</foo>

// I want to make a nested hash  %xml that contains ALL the data. (nevermind
// attributes at this time)
// Example:
// $xml{'parent'}->{'child'}->{'subchild'} = 'value';

So.... what happens if you want to parse:

    <section><para>text 1</para>
             <para>text 2</para>
   </section>

And what happens to ordering in general?

// PROBLEM:
// I don't know how deep the xml goes, so there's no limit to the nesting...

And?

// How do i do this?

Well, the answer is trivial, use references. Are you sure you are up to the
task of parsing XML when you can't figure this one out?



Abigail
-- 
@_=map{[$!++,$_^$/]}split$²,"\@\x7Fy~*kde~box*Zoxf*Bkiaox";$\="\r";
$|=++$*;do{($#,$=)=(rand@_,rand@_);@_[$#,$=]=@_[$=,$#]}for($*..@_);
for$:($|..@_-$|){for($|..@_-$:){@_[$_-$|,$_]=@_[$_=>$_-$*]if$_[$_][
$¼]<$_[$_-$*][$®];print+map{$_->[$|]}@_;select$·,$°,$½,0.1}}print$/


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

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 4263
**************************************


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