[18339] in Perl-Users-Digest
Perl-Users Digest, Issue: 507 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Mar 16 18:05:52 2001
Date: Fri, 16 Mar 2001 15:05:25 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <984783925-v10-i507@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Fri, 16 Mar 2001 Volume: 10 Number: 507
Today's topics:
Re: -w and use strict; <klacquement@syscor.com>
Re: -w and use strict; <wuerz@yahoo.com>
Re: -w and use strict; <mjcarman@home.com>
Re: -w and use strict; <uri@sysarch.com>
Re: -w and use strict; <uri@sysarch.com>
Re: -w and use strict; <wuerz@yahoo.com>
Re: -w and use strict; <mjcarman@home.com>
Re: -w and use strict; <dhwild@argonet.co.uk>
Re: -w and use strict; <klacquement@syscor.com>
Re: `pwd` doesn't work on all servers? <bart.lateur@skynet.be>
Algorithms: Cluster analysis w/ Perl? <wall@chop.swmed.edu>
Re: binary files <uri@sysarch.com>
Re: chomp not chomping? <mjcarman@home.com>
Distributive -> and indirect slices <david@freemm.org>
Re: Distributive -> and indirect slices <dan@tuatha.sidhe.org>
Re: FAQ 7.18: What's the difference between deep and <godzilla@stomp.stomp.tokyo>
Re: FAQ 7.18: What's the difference between deep and <uri@sysarch.com>
Re: FAQ 7.18: What's the difference between deep and (Logan Shaw)
Re: Funny regular expression problem (Jay Tilton)
Re: Funny regular expression problem <maheshasolkar@yahoo.com>
Re: Funny regular expression problem (Jay Tilton)
Re: Getopt::Std swallows argument even if ":" not speci (LMC)
Re: Getopt::Std swallows argument even if ":" not speci (Johan Vromans)
Re: Godzilla! Do you please your ego by insulting peopl <godzilla@stomp.stomp.tokyo>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 16 Mar 2001 11:12:38 -0800
From: Kevin Lacquement <klacquement@syscor.com>
Subject: Re: -w and use strict;
Message-Id: <m2lmq5fryx.fsf@aridhol.syscor.priv>
>>>>> "LM" == Lou Moran <lmoran@wtsg.com> writes:
[...]
LM> My questions are:
LM> Do you remove those once your script works as expected and is
LM> unlikely to be changed?
^^^^^^^^^^^^^^^^^^^^^^
Note that this is _completely_ different from 'never will be changed'.
IMHO, any script that never changes is a dead project, a cheap hack,
or a school assignment.
LM> Does it make the script faster not to have those up top?
I don't think so. AFAICT, these affect the compilation of the script,
which happens at the beginning of the run; after that, there shouldn't
be any effect.
LM> Are there good reasons not to use those things?
You're writing a cheap hack or school assignment? Alternatively, if
you want to intentionally abuse the language, you can do this. Just
don't leave them out in anything that you expect to be used for
important work. In my book, that includes system administration.
Cheers,
Kevin
--
He that breaks a thing to find out what it is has left the path of
wisdom -- Gandalf the Grey
------------------------------
Date: Fri, 16 Mar 2001 20:16:33 +0100
From: Mona Wuerz <wuerz@yahoo.com>
Subject: Re: -w and use strict;
Message-Id: <160320012016334116%wuerz@yahoo.com>
In article <m2lmq5fryx.fsf@aridhol.syscor.priv>, Kevin Lacquement
<klacquement@syscor.com> wrote:
> >>>>> "LM" == Lou Moran <lmoran@wtsg.com> writes:
>
> LM> Do you remove those once your script works as expected and is
> LM> unlikely to be changed?
> ^^^^^^^^^^^^^^^^^^^^^^
>
> Note that this is _completely_ different from 'never will be changed'.
> IMHO, any script that never changes is a dead project, a cheap hack,
> or a school assignment.
Actually, no. I've wondered the same thing as the OP. What I usually do
is to develop on one machine exclusively, and have the scripts run on
another. So I always have one development copy which is generally half
a step ahead of the copy that does the actual work. Whenever the
development copy is ready (and tested to death, of course), the working
copy is replaced. In this sense, the project is alive, yet the working
copy most definitely 'never will be changed.' So no, it's not a trivial
question (to me, at least) -- should I leave the -w and use strict in
the working copy?
-mona
------------------------------
Date: Fri, 16 Mar 2001 12:58:36 -0600
From: Michael Carman <mjcarman@home.com>
Subject: Re: -w and use strict;
Message-Id: <3AB2625C.39CD01C1@home.com>
Lou Moran wrote:
>
> --Since I have been Learning Perl and Programming Perl I have always
> started my thinga-ma-bobs (since I'm not too sure if I am scripting or
> programming) with:
>
> #!/usr/bin/perl -w
> use strict;
Excellent.
> even when I do the coding in WIN32. I recently came across a pretty
> good book WIN32 Perl Scripting : The Administrator's Handbook (New
> Riders (Roth)) that NEVER uses either the -w or use strict;.
>
[...]
>
> Do you remove those once your script works as expected and is unlikely
> to be changed?
Some people prefer using -w only for development. That way users
shouldn't ever see warnings (which mean nothing to them) after
deployment. Personally, I write my code with -w and never take it out.
Occasionally I'll be using (not writing/debugging) one of my own
programs and it will uncover bugs/loopholes that I never even knew I
had. Usually, a program that is developed to be quiet under -w will stay
quiet without needing to take it out.
I see no reason to ever remove 'use strict' as it has no runtime effect.
> Does it make the script faster not to have those up top?
No, not appreciably at least. You might save a tiny sliver of compile
time getting rid of strict. Removing -w should have no efficiency impact
unless you're code generates tons of warnings (which can take a while to
print on STDERR).
> Are there good reasons not to use those things?
Sometimes strict is too strict. You probably don't want to declare all
your variables for a quick throw-away script, on (exceedingly) rare
occasions you might need to use symrefs, etc. The world might be a
better place, though, if -w and 'use strict' were the default, and you
had to explicitly turn these things *off* when you didn't want them. :)
-mjc
------------------------------
Date: Fri, 16 Mar 2001 20:11:59 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: -w and use strict;
Message-Id: <x7ae6l79td.fsf@home.sysarch.com>
>>>>> "MW" == Mona Wuerz <wuerz@yahoo.com> writes:
MW> In article <m2lmq5fryx.fsf@aridhol.syscor.priv>, Kevin Lacquement
MW> <klacquement@syscor.com> wrote:
>> >>>>> "LM" == Lou Moran <lmoran@wtsg.com> writes:
>>
LM> Do you remove those once your script works as expected and is
LM> unlikely to be changed?
>> ^^^^^^^^^^^^^^^^^^^^^^
>>
>> Note that this is _completely_ different from 'never will be changed'.
>> IMHO, any script that never changes is a dead project, a cheap hack,
>> or a school assignment.
MW> Actually, no. I've wondered the same thing as the OP. What I usually do
MW> is to develop on one machine exclusively, and have the scripts run on
MW> another. So I always have one development copy which is generally half
MW> a step ahead of the copy that does the actual work. Whenever the
MW> development copy is ready (and tested to death, of course), the working
MW> copy is replaced. In this sense, the project is alive, yet the working
MW> copy most definitely 'never will be changed.' So no, it's not a trivial
MW> question (to me, at least) -- should I leave the -w and use strict in
MW> the working copy?
well, strict is a purely compile time feature that shouldn't add any
overhead to a script. it just barfs if things aren't properly
declared. so theoretically you could remove it from production if it
passes but there is no gain in doing so.
-w has both compile time and runtime effects. it spits out various
useful compile time errors like variable used only once, etc. if you
don't get any of those with -w, then it isn't needed. but i doubt you
can test for every one of the runtime errors that -w finds. no test/dev
enviornment is ever as harsh as the real world. so i would always leave
-w on to find those bugs (and if -w reports something, it IS a bug) even
in production. the runtime overhead is very small but the safety
improvements are very large. well worth it.
so, i would just always leave both. it means you don't have to worry
about deleting them before sending a program to production, it means if
some moron copies the production programs and decides to mung it, he
will still be protected somewhat. there is no major win to removing them
and definitely potential losses if they are not there.
BTW, strict is a per file (compile time, remember) feature. it has to be
in every module you write or use. -w is a global flag and needs only to
be set once. the new 5.6 use warnings is file scoped like strict and has
to be in each file.
uri
--
Uri Guttman --------- uri@sysarch.com ---------- http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page ----------- http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net ---------- http://www.northernlight.com
------------------------------
Date: Fri, 16 Mar 2001 20:21:28 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: -w and use strict;
Message-Id: <x77l1p79dk.fsf@home.sysarch.com>
>>>>> "MC" == Michael Carman <mjcarman@home.com> writes:
MC> Sometimes strict is too strict. You probably don't want to declare
MC> all your variables for a quick throw-away script, on (exceedingly)
MC> rare occasions you might need to use symrefs, etc. The world might
MC> be a better place, though, if -w and 'use strict' were the
MC> default, and you had to explicitly turn these things *off* when
MC> you didn't want them. :)
if you need to use symrefs (usually only needed when actually munging
the symbol tables), just put a no strict command in the tightest block
around that code. never remove use strict from the whole program just to
turn it off in one place.
as for enabling it all the time, what would that do to one liners and
very short scripts? they would become much more annoying to write. it is
better to keep it this way. you know when a script or module will be
used a great deal and its potential size. so you put use strict in and
move on.
uri
--
Uri Guttman --------- uri@sysarch.com ---------- http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page ----------- http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net ---------- http://www.northernlight.com
------------------------------
Date: Fri, 16 Mar 2001 21:37:37 +0100
From: Mona Wuerz <wuerz@yahoo.com>
Subject: Re: -w and use strict;
Message-Id: <160320012137374386%wuerz@yahoo.com>
In article <x7ae6l79td.fsf@home.sysarch.com>, Uri Guttman
<uri@sysarch.com> wrote:
> [about -w and strict]
Thanks, also to Michael Carman, who essentially said the same thing in
a different branch of this thread.
Actually, the only occasion where this has been an actual issue for me
was when I noticed that certain modules that are part of the standard
installation are not strict and -w clean (Mac::Types, for one). Easy
enough to fix the modules directly on my machine, but a pain if someone
else uses the script on theirs.
I know the answer to the problem, of course, I just wanted to whine
about it somewhere.
-mona
------------------------------
Date: Fri, 16 Mar 2001 14:59:29 -0600
From: Michael Carman <mjcarman@home.com>
Subject: Re: -w and use strict;
Message-Id: <3AB27EB1.57D98AF@home.com>
Uri Guttman wrote:
>
> never remove use strict from the whole program just to turn it
> off in one place.
Oops, I didn't mean to suggest that! I can see how someone might have
interpreted it that way, though. :/
> as for enabling [strict] all the time, what would that do to one
> liners and very short scripts? they would become much more annoying
> to write. it is better to keep it this way.
Oh, I know. I wasn't serious -- just thinking wishfully about how much
that might cut down on all the posts here asking how to do symbolic
references.
-mjc
------------------------------
Date: Fri, 16 Mar 2001 20:44:17 +0000 (GMT)
From: David H Wild <dhwild@argonet.co.uk>
Subject: Re: -w and use strict;
Message-Id: <4a5c5182fcdhwild@argonet.co.uk>
In article <m2lmq5fryx.fsf@aridhol.syscor.priv>,
Kevin Lacquement <klacquement@syscor.com> wrote:
> LM> Do you remove those once your script works as expected and is
> LM> unlikely to be changed?
> ^^^^^^^^^^^^^^^^^^^^^^
> Note that this is _completely_ different from 'never will be changed'.
> IMHO, any script that never changes is a dead project, a cheap hack,
> or a school assignment.
It **might** be reasonable to argue that a script which is being
distributed isn't going to change while the users have it. If you are going
to change it later you can put the -w, etc in again and send out new
scripts.
--
__ __ __ __ __ ___ _____________________________________________
|__||__)/ __/ \|\ ||_ | / Acorn StrongArm Risc_PC
| || \\__/\__/| \||__ | /...Internet access for all Acorn RISC machines
___________________________/ dhwild@argonet.co.uk
------------------------------
Date: 16 Mar 2001 14:18:01 -0800
From: Kevin Lacquement <klacquement@syscor.com>
Subject: Re: -w and use strict;
Message-Id: <m2bsr1iciu.fsf@aridhol.syscor.priv>
>>>>> "DHW" == David H Wild <dhwild@argonet.co.uk> writes:
DHW> In article <m2lmq5fryx.fsf@aridhol.syscor.priv>,
DHW> Kevin Lacquement <klacquement@syscor.com> wrote:
LM> Do you remove those once your script works as expected and is
LM> unlikely tyo be changed?
>> ^^^^^^^^^^^^^^^^^^^^^^
>> Note that this is _completely_ different from 'never will be
>> changed'. IMHO, any script that never changes is a dead
>> project, a cheap hack, or a school assignment.
DHW> It **might** be reasonable to argue that a script which is
DHW> being distributed isn't going to change while the users have
DHW> it. If you are going to change it later you can put the -w,
DHW> etc in again and send out new scripts.
If those users are also programmers, they may want to tweak the
script. In that case, -w and strict help them.
Cheers,
Kevin
--
He that breaks a thing to find out what it is has left the path of
wisdom -- Gandalf the Grey
------------------------------
Date: Fri, 16 Mar 2001 22:54:03 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: `pwd` doesn't work on all servers?
Message-Id: <6c65btgik08nq1j0eulidegi37qtq6gin8@4ax.com>
John W. Krahn wrote:
>perldoc Cwd
>
>SYNOPSIS
> use Cwd;
> $dir = cwd;
Note that I have a server where cwd() returns an empty string. So the
problem is not limited to `pwd`. (There, too, logged in as me, cwd does
work, but not though CGI.)
--
Bart.
------------------------------
Date: Thu, 15 Mar 2001 17:15:35 -0600
From: wall <wall@chop.swmed.edu>
Subject: Algorithms: Cluster analysis w/ Perl?
Message-Id: <3AB14D16.80CD1759@chop.swmed.edu>
I appeal to your sense of mathmatics. I have looked far and wide for
Perl algorithms to carry out cluster analysis (nearest neighbor,
centroid ...). I must humble myself and admit defeat, but appeal to
higher minds.
Are there such routines available?
Can those with such programming skills give me advice?
if (yes) {
please copy your answer to wall@chop.swmed.edu;
}
Thank you,
Mark Wall
wall@chop.swmed.edu
------------------------------
Date: Fri, 16 Mar 2001 19:38:43 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: binary files
Message-Id: <x7lmq57bcs.fsf@home.sysarch.com>
>>>>> "BL" == Bart Lateur <bart.lateur@skynet.be> writes:
BL> Uri Guttman wrote:
>> many mainframes and vaxes support decimal math in hardware but that is
>> BCD.
BL> ...
>> then we wouldn't have to hear about all
>> the rounding issues from float newbies. :)
BL> Only if those machines use BigFloats instead of real floats. "BCD" is
BL> not a magical solution.
it does solve many of the basic binary/decimal conversions issues we see
within a normal range of numbers/integers. 15 or 31 decimal digits is a
pretty wide range. so .3 + .7 would work as expected with no problems,
unlike in binary. in fact that is why decimal is supported in cobol/pl1
and on maniframes. they didn't want their poor programmers worrying
about binary conversion issues. (almost?) none of the current 32/64 bit
chips support decimal since those instructions are the acme of
CISC. they are VERY complicated and take many cycles to run. no, bcd is
not a perfect solution but it does solve many problems at a cost of
both speed and memory.
uri
--
Uri Guttman --------- uri@sysarch.com ---------- http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page ----------- http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net ---------- http://www.northernlight.com
------------------------------
Date: Fri, 16 Mar 2001 14:05:21 -0600
From: Michael Carman <mjcarman@home.com>
Subject: Re: chomp not chomping?
Message-Id: <3AB27201.FC3B5B94@home.com>
Jim Kroger wrote:
>
> Hi, I have the following code, in which chomp seems not to be doing its
> job, and leaves junk attached to the end of an item:
What is it that you expect chomp() to be doing? Did you read the manpage
for the function?
chomp LIST
This safer version of chop removes any trailing string that
corresponds to the current value of $/
[...]
Unless you've explicitly changed it, $/ will be the default value of
"\n" -- a newline.
> chomp(@subjects = `cat subNames`);
Too lazy to open and read the file yourself? ;)
> foreach (@subjects) {
> chomp($_);
> }
Completely redundant with the earlier chomp(), as you thought it should
be. If something doesn't work, doing it twice won't help!
> CHOMP DOESN'T SEEM TO WORK:
> [I]n the debugger, typing
>
> x @subjects
>
> after the first snippet above seems not to clean up the end of the
> item and returns the subjects with something appended to each
> (carriage return?):
>
> "anna/cI"
> "baig/cI"
> -
> -
That isn't a carriage return, it's a control-I, which is the tab
character. chomp() doesn't remove those (unless you change $/
appropriately). Use
s/^\s+//;
s/\s+$//;
to remove leading and trailing whitespace.
-mjc
------------------------------
Date: Fri, 16 Mar 2001 20:43:24 GMT
From: "David M. Lloyd" <david@freemm.org>
Subject: Distributive -> and indirect slices
Message-Id: <Pine.LNX.4.21.0103131626180.10583-100000@homebody.freemm.org>
I have an idea that I'm going to try to put into my Perl, but I want some
'professional' opinions on it first.
The first thing I'd like to do, is make the -> operator 'distributive' for
all cases of it (that I can think of anyways).
Examples:
# Call $x->foo(); and $y->foo(); instead of
# current, less-useful $y->foo();
($x, $y)->foo();
# Call foo() for all @bar instead of
# current 'Can't call method ... without a package or object
# reference'
@bar->foo();
# Call both functions with args
($coderef1, $coderef2)->('Param1', 2);
# Return (1, 3) in list context as lvalues
([1, 2], [3, 4])->[0];
# Return (1234, 5432) (hash derefs) in list context as lvalues
({'key' => 1234}, {'key' => 5432})->{'key'};
This would be different from the standard -> notation in that the left
side of the value is a list or array, instead of a scalar. This
distinction makes it possible to allow the -> notation to create indirect
slices:
@arrayrefs->[1..3];
because I can say (hopefully), "If the left side is a list, then the index
is also a list". This logic would allow things like this:
($structure)->[1,3,7]->{'key1', 'key2'}; # Returns 6 things
Or this, to get really nuts:
# foo() is called in list context...
@structure->[2,0,3,1]->{'keyA', 'keyB', 'keyC'}->foo();
which calls 12 foo()s for each thing in @structure, in this order:
$structure[0]->[2]->{'keyA'}->foo();
$structure[0]->[2]->{'keyB'}->foo();
$structure[0]->[2]->{'keyC'}->foo();
$structure[0]->[0]->{'keyA'}->foo();
$structure[0]->[0]->{'keyB'}->foo();
$structure[0]->[0]->{'keyC'}->foo();
$structure[0]->[3]->{'keyA'}->foo();
$structure[0]->[3]->{'keyB'}->foo();
$structure[0]->[3]->{'keyC'}->foo();
$structure[0]->[1]->{'keyA'}->foo();
$structure[0]->[1]->{'keyB'}->foo();
$structure[0]->[1]->{'keyC'}->foo();
and returns the return values of foo() as one big long list.
Or this, to use a simple slice on a reference:
($arrayref)->[0..15]; # The () gives me list context
Without changing the behaviour of this:
# Still returns boring old $arrayref->[0]
$arrayref->[0..15];
or this:
# Still returns boring old $arrayref->[15]
$arrayref->[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15];
I was looking at perly.y and I was kind of thinking that I would need to
change the various 'term ARROW ...' rules to do some sort of check on the
left-hand side.
Is this worth investigating? Is there any chance that such behaviour
would ever be integrated into Perl 5? What about Perl 6?
Thanks for any feedback!
- D
<david@freemm.org>
------------------------------
Date: Fri, 16 Mar 2001 21:21:23 GMT
From: Dan Sugalski <dan@tuatha.sidhe.org>
Subject: Re: Distributive -> and indirect slices
Message-Id: <ntvs6.38364$Ok4.3605472@news1.rdc1.ct.home.com>
David M. Lloyd <david@freemm.org> wrote:
> I have an idea that I'm going to try to put into my Perl, but I want some
> 'professional' opinions on it first.
The changes to the parser and tokenizer for this will probably
be non-trivial, especially when you have to take all the cases
into consideration. (What do you do when the list on the left
has some hash references and some objects and some array
references and some sub references, for example?)
> Is this worth investigating? Is there any chance that such behaviour
> would ever be integrated into Perl 5? What about Perl 6?
No, and yes if Larry's OK with it, respectively.
Try it, and if you get it working on perl 5, do please come on
over to the perl 6 internals list--I could use those skills.
Dan
------------------------------
Date: Fri, 16 Mar 2001 11:46:15 -0800
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: FAQ 7.18: What's the difference between deep and shallow binding?
Message-Id: <3AB26D87.6578F315@stomp.stomp.tokyo>
PerlFAQ Server wrote:
> What's the difference between deep and shallow binding?
> In deep binding, lexical variables mentioned in anonymous subroutines
> are the same ones that were in scope when the subroutine was created. In
> shallow binding, they are whichever variables with the same names happen
> to be in scope when the subroutine is called. Perl always uses deep
> binding of lexical variables (i.e., those created with my()). However,
> dynamic variables (aka global, local, or package variables) are
> effectively shallowly bound. Consider this just one more reason not to
> use them. See the answer to the section on "What's a closure?".
"Consider this just one more reason not to use them."
This is stereotypical Perl 5 Cargo Cultist dogma.
Global variables are exceptionally important and
should be used, when appropriate, for better script
speed and better efficiency.
Perl core contains many default global variables for
convenience in programming. Other global variables
include, as an important example, environmental
variables, which are numerous and global. In many
cases, use of local () is the only option to attain
a specific goal. An example would be $/ and changing
its global default value to meet unique circumstances.
This FAQ's advice would have a programmer never use
these global variables exemplified nor any global
variables which are critical to effective programming.
This FAQ statement, "Consider this just one more reason
not to use them." is pure mule manure and is exceptionally
poor advice reflecting a lack of sound thinking amongst
Perl 5 Cargo Cultists promulgating a political doctrine
rather than providing factual information.
Godzilla!
------------------------------
Date: Fri, 16 Mar 2001 20:30:59 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: FAQ 7.18: What's the difference between deep and shallow binding?
Message-Id: <x74rwt78xp.fsf@home.sysarch.com>
>>>>> "G" == Godzilla! <godzilla@stomp.stomp.tokyo> writes:
G> "Consider this just one more reason not to use them."
G> This is stereotypical Perl 5 Cargo Cultist dogma.
G> Global variables are exceptionally important and
G> should be used, when appropriate, for better script
G> speed and better efficiency.
and that is very typical bullshit from you. globals do not provide any
different efficiency than lexical vars. but talking about efficency with
you is not worth it. you don't even understand basic algorithmic
theory. try to explain to anyone here what O( N ) means. i would love to
see it.
G> Perl core contains many default global variables for convenience in
G> programming. Other global variables include, as an important
G> example, environmental variables, which are numerous and global. In
G> many cases, use of local () is the only option to attain a specific
G> goal. An example would be $/ and changing its global default value
G> to meet unique circumstances.
perl's built in special variables (not all of which are global) have
nothing to do with declaring your own variables lexically or
globally. it is not a valid argument. perl's special variables CANNOT be
made lexical since they are IN THE SYMBOL TABLE otherwise perl COULD NOT
SEE THEM!!. the whole point of having special variables is for PERL TO
SEE THEM AND PERL CANNOT SEE LEXICAL VARS!. therefore they have to
be localized to keep their values private to some scope. that is not an
argument for making all of your regular variables have the same dynamic
scope.
G> This FAQ's advice would have a programmer never use these global
G> variables exemplified nor any global variables which are critical
G> to effective programming.
you are confusing perl's special variables with programmer ones. you can
have file level globals with my just fine and no one objects. the issue
is totally whether a variable is IN THE SYMBOL TABLE. you don't grasp
that important point. it has nothing to do with efficiency or any
diatribe against globals.
G> This FAQ statement, "Consider this just one more reason not to use
G> them." is pure mule manure and is exceptionally poor advice
G> reflecting a lack of sound thinking amongst Perl 5 Cargo Cultists
G> promulgating a political doctrine rather than providing factual
G> information.
please go write a book and send it to me. i need some more kindling. you
have no idea what you are talking about as usual. i write this just to
make sure others who don't know about you keep away from your bullshit.
i fully expect a childish followup about your ignoring this. try and
read what i said. globals and lexicals are TWO DIFFERENT SUBJECTS. you
constantly combine them into one. so you argument (if you can even call
your drivel that) has no ground to stand on.
uri
--
Uri Guttman --------- uri@sysarch.com ---------- http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page ----------- http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net ---------- http://www.northernlight.com
------------------------------
Date: 16 Mar 2001 14:58:40 -0600
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: FAQ 7.18: What's the difference between deep and shallow binding?
Message-Id: <98tuq0$he$1@boomer.cs.utexas.edu>
In article <3AB26D87.6578F315@stomp.stomp.tokyo>,
Godzilla! <godzilla@stomp.stomp.tokyo> wrote:
>This FAQ's advice would have a programmer never use
>these global variables exemplified nor any global
>variables which are critical to effective programming.
Global variables are not critical to effective programming.
For example, pure functional programming languages have no variables
whatsoever (global or local), and it is possible to program in them
effectively. (Whether that suits anyone's taste is a separate
question.)
Also, the object-oriented approach to programming will generally allow
you to eliminate global variables by making them part of some object.
In fact, when you do so, you usually end up with a better design
anyway, since you find that the global variable's existence was a
symptom of not having a necessary object in your model.
If I weren't too busy to follow this thread, I would challenge you to
give a single example of a situation when a global variable is useful,
not including those times when you must use a global variable because
that is the only interface that Perl provides.
- Logan
--
whose? my your his her our their _its_
who's? I'm you're he's she's we're they're _it's_
------------------------------
Date: Fri, 16 Mar 2001 19:31:37 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: Funny regular expression problem
Message-Id: <3ab265ef.129145524@news.erols.com>
On Fri, 16 Mar 2001 12:34:01 -0500, "Steve D. Perkins"
<steve@NOSPAM.hotmail.com> wrote:
># Columns can be seperated by tabs or spaces
It sounds like 'split' would be perfectly suited to this task.
my @columns = split /\s+/, $foo;
perldoc -f split
> However, I'm not getting the results I expected! The first real expression returns
>everything through the final double-quote rather than the first:
That's the regex '*' quantifier being greedy.
perldoc -q greedy
------------------------------
Date: Fri, 16 Mar 2001 11:49:37 -0800
From: "Mahesh A" <maheshasolkar@yahoo.com>
Subject: Re: Funny regular expression problem
Message-Id: <tb4rin3u97p321@corp.supernews.com>
"Steve D. Perkins" <steve@NOSPAM.hotmail.com> wrote in message
news:98tirt02snp@news2.newsguy.com...
[..]
>
> # Lines beginning with pound-signs are considered comments and ignored
> # First column is a 2-to-4 character alphanumeric system code
> # Second column is an initialization string enclosed in double-quotes
> # Third colum is comma-delimited list of divisions within the system that
use this string
> # ...(can be asterisk to represent ALL systems)
> # Columns can be seperated by tabs or spaces
> D1 "DUMMY-INITIALIZATION-STRING" 123,456
> D1 "DUMMY-INITIALIZATION-STRING-FOR-789" 789
> D2 "DUMMY-INIT-4-ALL-WITHIN-D2" *
[..]
> FOR FIRST COLUMN (extract characters preceeding the first double-quote,
trim quote mark off
> later):
> "^.*[\"]"
>
> However, I'm not getting the results I expected! The first real
expression returns
> everything through the final double-quote rather than the first:
> D1 "DUMMY-INITIALIZATION-STRING"
This is a case of greedy regex.
'perldoc perlre', look for greedy. I think there's an FAQ on this too.
>
> ... the second expression does work fine:
> "DUMMY-INITIALIZATION-STRING"
>
I guess, it won't if there are more double-quoted strings in the line.
> ... although the third expression returns nothing at all (empty
string).
>
> Can anyone spot the (probably idiotic) error I'm making here, or
suggest expressions that
> would return what I need for the first and third columns?
>
>
I'd probably use a split here...
($First, $Secont, $Third) = split (/\s+/); # assuming $_ has the line.
- M.
------------------------------
Date: Fri, 16 Mar 2001 19:54:27 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: Funny regular expression problem
Message-Id: <3ab26b9e.130601179@news.erols.com>
Breaking protocol by following my own post.
>It sounds like 'split' would be perfectly suited to this task.
> my @columns = split /\s+/, $foo;
Unless that second column can contain spaces within the double quotes,
which could be why the quotes are used in the first place.
my @columns = split /\s*\"\s*/, $foo;
So split on the quotes (and possible surrounding whitespace) instead,
much like you were trying to do in the first place.
------------------------------
Date: Fri, 16 Mar 2001 14:34:45 -0500
From: "Antoine Beaupre (LMC)" <lmcabea@lmc.ericsson.se>
Subject: Re: Getopt::Std swallows argument even if ":" not specified?
Message-Id: <3AB26AD5.842C99@lmc.ericsson.se>
What chance would this modif have of getting into perl?
The idea here is that:
cmd.pl -v
and
cmd.pl -v -v -v -v -v
are intuitively not the same. This is a trivial change to increment the
entry each time the flag is encountered.
Should I send that to perlbug@perl.com? ;)
*** Std.pm.new Fri Mar 16 14:26:04 2001
--- /apps/perl5.005/lib/5.00503/Getopt/Std.pm Wed Mar 15 10:46:10 2000
***************
*** 129,148 ****
}
else {
if (ref $hash) {
! if (exists $$hash{$first}) {
! $$hash{$first}++;
! }
! else {
! $$hash{$first} = 1;
! }
}
else {
! if (defined ${"opt_$first"}) {
! ${"opt_$first"}++;
! }
! else {
! ${"opt_$first"} = 1;
! }
push( @EXPORT, "\$opt_$first" );
}
if($rest eq '') {
--- 129,138 ----
}
else {
if (ref $hash) {
! $$hash{$first} = 1;
}
else {
! ${"opt_$first"} = 1;
push( @EXPORT, "\$opt_$first" );
}
if($rest eq '') {
--
La sémantique est la gravité de l'abstraction.
------------------------------
Date: 16 Mar 2001 22:02:47 +0100
From: JVromans@Squirrel.nl (Johan Vromans)
Subject: Re: Getopt::Std swallows argument even if ":" not specified?
Message-Id: <m23dcda0lk.fsf@phoenix.squirrel.nl>
"Antoine Beaupre (LMC)" <lmcabea@lmc.ericsson.se> writes:
> What chance would this modif have of getting into perl?
>
> The idea here is that:
>
> cmd.pl -v
>
> and
>
> cmd.pl -v -v -v -v -v
>
> are intuitively not the same.
Getopt::Std is pretty basic, intentional.
The feature you requested, and many more things, is provided by
Getopt::Long, also part of the core.
-- Johan
------------------------------
Date: Fri, 16 Mar 2001 11:15:43 -0800
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Godzilla! Do you please your ego by insulting people. You may be god at Perl and a hotshot in this group, but hardly can you have a decent education.
Message-Id: <3AB2665E.C8743A2@stomp.stomp.tokyo>
Kalle Anka wrote:
> Godzilla! Do you please your ego by insulting people.
> You may be god at Perl and a hotshot in this group,
> but hardly can you have a decent education.
> Dont disturb yourself with my quests anymore.
I do as I please. However, I shall attempt to please you.
Would you like me to call you, Kalle, Lou or Frank?
OINK!
Godzilla!
------------------------------
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 V10 Issue 507
**************************************