[25498] in Perl-Users-Digest
Perl-Users Digest, Issue: 7742 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Feb 5 18:05:34 2005
Date: Sat, 5 Feb 2005 15:05:08 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Sat, 5 Feb 2005 Volume: 10 Number: 7742
Today's topics:
Re: Can't get perl to find .pm in my own private direct <mj@sci.fi>
Re: Equality of hashref objects (Anno Siegel)
Re: Invisible cache for LWP / Mechanize? (Anno Siegel)
Re: perl style: can I combine two steps into one? <postmaster@castleamber.com>
Re: perl style: can I combine two steps into one? <postmaster@castleamber.com>
Re: perl style: can I combine two steps into one? (Anno Siegel)
Re: perl style: can I combine two steps into one? (Anno Siegel)
Re: perl style: can I combine two steps into one? <rasto@gmx.at>
Re: perl style: can I combine two steps into one? <abigail@abigail.nl>
Re: perl style: can I combine two steps into one? <postmaster@castleamber.com>
Re: perl style: can I combine two steps into one? <abigail@abigail.nl>
Re: perl style: can I combine two steps into one? <postmaster@castleamber.com>
Re: perl style: can I combine two steps into one? <postmaster@castleamber.com>
Re: perl style: can I combine two steps into one? <postmaster@castleamber.com>
Re: perl style: can I combine two steps into one? <abigail@abigail.nl>
Re: perl style: can I combine two steps into one? <postmaster@castleamber.com>
Re: perl style: can I combine two steps into one? <postmaster@castleamber.com>
Re: perl style: can I combine two steps into one? <rasto@gmx.at>
Re: Why aren't 'warnings' on by default? <postmaster@castleamber.com>
Re: Why aren't 'warnings' on by default? <postmaster@castleamber.com>
Re: Why aren't 'warnings' on by default? <abigail@abigail.nl>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sat, 05 Feb 2005 23:43:36 +0200
From: MJ <mj@sci.fi>
Subject: Re: Can't get perl to find .pm in my own private directory
Message-Id: <LMbNd.1764$Ay2.404@reader1.news.jippii.net>
m_p_v_13 wrote:
> How do I add to the search paths for .pm modules in my local
> environment?
One thing that I do quite often while developing modules is:
use lib ".";
Then, I can put the module hierarchy right in the same directory and my project is self-contained
until it's ready to publish.
--
mj
------------------------------
Date: 5 Feb 2005 19:54:14 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Equality of hashref objects
Message-Id: <cu3896$e7m$1@mamenchi.zrz.TU-Berlin.DE>
bill <please_post@nomail.edu> wrote in comp.lang.perl.misc:
> In <1107543811.374991.63530@l41g2000cwc.googlegroups.com>
> "nobull@mail.com" <nobull@mail.com> writes:
>
> >bill wrote:
>
> >> I have a class that is implemented as a hashref, and furthermore,
> >> the values for the corresponding hash are always scalars. I want
> >> a sub to test for equality between any two instances of this class,
> >> defined roughly as "two instances $x and $y are equal if $x->{
> >> $field } and $y->{ $field } are equal for all instance fields
> >> $field". I took a crack at this function, but it is so *ugly* that
> >> I'm sure there must be a better way. I give my version below for
> >> your mocking pleasure. Any pointers to a better implementation
> >> would be much appreciated.
>
> >Data::Compare
>
> >> if (2 == grep $_is_numeric($_), @vals) {
> >> return 0 unless $vals[0] == $vals[1];
> >> }
> >> else {
> >> return 0 unless $vals[0] eq $vals[1];
> >> }
>
> >> $_is_numeric = sub {
> >> use warnings 'all', FATAL => 'numeric';
> >> return defined eval { $_[0] == 0 };
> >> };
>
> >This has the effect of treating the strings '0' and '0000000000' as the
> >same. Is that what you wanted?
>
> Yes, that was the intent.
>
> >What you you percieve as the problem
> >if you just use eq all the time?
>
> In this application it is far more likely for a "numeric" field to
> hold, say, '1.0' in one instance and '1.00' in another, than it is
> for a "string" field to hold a value for which $_is_numeric would
> return true. In fact, I am debating whether to change
Then ->new (or whatever) should take care that numeric fields are numeric
(by adding 0). Strings should also be normalized, if applicable. Usually.
> return 0 unless $vals[0] == $vals[1];
>
> to
>
> return 0 unless abs($vals[0], $vals[1]) < $EPSILON;
>
> for some tiny $EPSILON.
This sounds more and more like the wholesale approach "compare two hashes"
isn't the right one here. For general OO reasons, comparison should be
based on accessors, not on "wild" access to the underlying hash structure.
That some fields appear to need particular comparison routines is another
pointer in that direction. I'd say, the somewhat tedious
sub is_equal {
my ( $x, $y) = @_;
$x->some_field eq $y->some_field and
$x->other_field == $y->other_field and
abs( $x->third_field - $y->third_field) < EPS and
# ...
}
is the way to go. If there are very many fields some automation is
still possible.
Anno
------------------------------
Date: 5 Feb 2005 21:49:01 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Invisible cache for LWP / Mechanize?
Message-Id: <cu3f0d$hmn$1@mamenchi.zrz.TU-Berlin.DE>
jfix <jakob.fix@gmail.com> wrote in comp.lang.perl.misc:
Please give an attribution.
> Gisle,
> > $ua->default_header( Cache_Control => "no-cache" );
>
> you're right, of course, as regards the shortcutting. however, using
> strict I cannot use the bareword Cache_Control.
Yes, you can. See "perldoc perldata", look for "=>".
Anno
------------------------------
Date: 5 Feb 2005 19:48:46 GMT
From: John Bokma <postmaster@castleamber.com>
Subject: Re: perl style: can I combine two steps into one?
Message-Id: <Xns95F48C827B486castleamber@130.133.1.4>
Anno Siegel wrote:
> John Bokma <postmaster@castleamber.com> wrote in comp.lang.perl.misc:
>> Michael Slass wrote:
>
>
>> >| ++$hack_count{$1};
>>
>> I recommend using $hack_count{$1}++;
>
> Why?
Post increment is more used, and hence more natural to read. I only use pre
increment when it does matter. If I see ++$var I wonder what is happening
there. Like another example I posted last week somewhere else:
(pseudocode)
i = 0
while (true) {
i++;
last if i >= 10;
}
I consider >= 10 misleading if the previous statement is the only one that
modifies i. It can't get > 10 , so why test for it?
--
John Small Perl scripts: http://johnbokma.com/perl/
Perl programmer available: http://castleamber.com/
Happy Customers: http://castleamber.com/testimonials.html
------------------------------
Date: 5 Feb 2005 19:52:19 GMT
From: John Bokma <postmaster@castleamber.com>
Subject: Re: perl style: can I combine two steps into one?
Message-Id: <Xns95F48D1CD751Bcastleamber@130.133.1.4>
Anno Siegel wrote:
> less of one. The final (top) step is unnecessary and missing now,
> so it's only half of a Schwartzian still.
>
> sort { $b->[ 1] <=> $a->[ 1] }
> map [ $_, $hack_count{ $_}],
> keys %hack_count;
An Artzian transform :-D.
BTW, why a space before the 1 and not after? I use for some time a lot of
white space, ie:
sort { $b->[ 1 ] <=> $a->[ 1 ] }
map [ $_, $hack_count{ $_ } ],
keys %hack_count;
(just curious) I might even line up a bit, e.g.
sort { $b->[ 1 ] <=> $a->[ 1 ] }
map [ $_, $hack_count{ $_ } ],
keys %hack_count;
(probably has a lot to do with using a 10pt font :-) ).
--
John Small Perl scripts: http://johnbokma.com/perl/
Perl programmer available: http://castleamber.com/
Happy Customers: http://castleamber.com/testimonials.html
------------------------------
Date: 5 Feb 2005 20:11:55 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: perl style: can I combine two steps into one?
Message-Id: <cu39ab$emd$1@mamenchi.zrz.TU-Berlin.DE>
John Bokma <postmaster@castleamber.com> wrote in comp.lang.perl.misc:
> Anno Siegel wrote:
>
> > John Bokma <postmaster@castleamber.com> wrote in comp.lang.perl.misc:
> >> Michael Slass wrote:
> >
> >
> >> >| ++$hack_count{$1};
> >>
> >> I recommend using $hack_count{$1}++;
> >
> > Why?
>
> Post increment is more used, and hence more natural to read. I only use pre
> increment when it does matter. If I see ++$var I wonder what is happening
> there.
It is more frequently used, but for no good reason. Pre-increment is
the simpler process, not only implementationally. There are two values
involved in $x++, but only one in ++$x. I'm not very consequent about it,
but I'm trying to give "++ $x" a better chance.
> Like another example I posted last week somewhere else:
> (pseudocode)
>
> i = 0
> while (true) {
>
>
> i++;
> last if i >= 10;
> }
>
> I consider >= 10 misleading if the previous statement is the only one that
> modifies i. It can't get > 10 , so why test for it?
That hinges entirely on the clause "... only (statement) that modifies i",
amended by "and there never will be another one". I take ">=" comparison
of loop indices for granted as a bit of defensive programming, it doesn't
confuse me.
Anno
------------------------------
Date: 5 Feb 2005 20:38:10 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: perl style: can I combine two steps into one?
Message-Id: <cu3ari$fic$1@mamenchi.zrz.TU-Berlin.DE>
John Bokma <postmaster@castleamber.com> wrote in comp.lang.perl.misc:
> Anno Siegel wrote:
>
> > less of one. The final (top) step is unnecessary and missing now,
> > so it's only half of a Schwartzian still.
> >
> > sort { $b->[ 1] <=> $a->[ 1] }
> > map [ $_, $hack_count{ $_}],
> > keys %hack_count;
>
> An Artzian transform :-D.
>
> BTW, why a space before the 1 and not after? I use for some time a lot of
> white space, ie:
>
> sort { $b->[ 1 ] <=> $a->[ 1 ] }
> map [ $_, $hack_count{ $_ } ],
> keys %hack_count;
>
> (just curious) I might even line up a bit, e.g.
I lump together closing brackets of all kind, unless I want one to stand
out. You don't want to miss an opening bracket, but the closing ones only
confirm what you know. A lump of them can be parsed as "this closes
everything" (up to a point that can be indicated through indentation).
I have carried this over from Lisp (where it's standard, though with only
one kind of bracket), but it works with most languages. It is also
kind of a personal hallmark. I know it is not particularly pretty,
especially in short bits of code.
Anno
------------------------------
Date: Sat, 05 Feb 2005 21:42:22 +0100
From: Rasto Levrinc <rasto@gmx.at>
Subject: Re: perl style: can I combine two steps into one?
Message-Id: <42052ebc$0$11352$3b214f66@tunews.univie.ac.at>
John Bokma wrote:
> there. Like another example I posted last week somewhere else:
>
> (pseudocode)
>
> i = 0
> while (true) {
>
>
> i++;
> last if i >= 10;
> }
>
> I consider >= 10 misleading if the previous statement is the only one that
> modifies i. It can't get > 10 , so why test for it?
>
The reason for that is, that if there is some obscure bug in the code,
it is less likely, that the program will run in endless loop. I was told
so, maybe 10 years ago and I am doing it like this ever since, without
much thinking about this. But probably it was never needed. :-)
--
Rasto Levrinc
http://sourceforge.net/projects/rlocate/
------------------------------
Date: 05 Feb 2005 21:48:53 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: perl style: can I combine two steps into one?
Message-Id: <slrnd0afq5.g2.abigail@alexandra.abigail.nl>
John Bokma (postmaster@castleamber.com) wrote on MMMMCLXXVI September
MCMXCIII in <URL:news:Xns95F48D1CD751Bcastleamber@130.133.1.4>:
][ Anno Siegel wrote:
][
][ > sort { $b->[ 1] <=> $a->[ 1] }
][
][ BTW, why a space before the 1 and not after? I use for some time a lot of
][ white space, ie:
The two lines above contain two commas, a question mark and a colon.
Each of them are followed by space, but not preceeded by any.
Why?
Abigail
--
perl -wle'print"Κυστ αξοτθες Πεςμ Θαγλες"^"\x80"x24'
------------------------------
Date: 5 Feb 2005 21:57:15 GMT
From: John Bokma <postmaster@castleamber.com>
Subject: Re: perl style: can I combine two steps into one?
Message-Id: <Xns95F4A24A7B4C2castleamber@130.133.1.4>
Anno Siegel wrote:
> John Bokma <postmaster@castleamber.com> wrote in comp.lang.perl.misc:
>> Anno Siegel wrote:
>>
>> > John Bokma <postmaster@castleamber.com> wrote in
>> > comp.lang.perl.misc:
>> >> Michael Slass wrote:
>> >
>> >
>> >> >| ++$hack_count{$1};
>> >>
>> >> I recommend using $hack_count{$1}++;
>> >
>> > Why?
>>
>> Post increment is more used, and hence more natural to read. I only
>> use pre increment when it does matter. If I see ++$var I wonder what
>> is happening there.
>
> It is more frequently used, but for no good reason. Pre-increment is
> the simpler process, not only implementationally. There are two
> values involved in $x++, but only one in ++$x.
A programmer shouldn't be bothered by that in normal cases.
> I'm not very
> consequent about it, but I'm trying to give "++ $x" a better chance.
To me that sounds like sacrifycing readability.
> That hinges entirely on the clause "... only (statement) that modifies
> i", amended by "and there never will be another one".
Yup.
> I take ">="
> comparison of loop indices for granted as a bit of defensive
> programming,
So you prefer your program silently to move on?
--
John Small Perl scripts: http://johnbokma.com/perl/
Perl programmer available: http://castleamber.com/
Happy Customers: http://castleamber.com/testimonials.html
------------------------------
Date: 05 Feb 2005 21:57:20 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: perl style: can I combine two steps into one?
Message-Id: <slrnd0aga0.g2.abigail@alexandra.abigail.nl>
John Bokma (postmaster@castleamber.com) wrote on MMMMCLXXVI September
MCMXCIII in <URL:news:Xns95F48C827B486castleamber@130.133.1.4>:
\\ Anno Siegel wrote:
\\
\\ > John Bokma <postmaster@castleamber.com> wrote in comp.lang.perl.misc:
\\ >> Michael Slass wrote:
\\ >
\\ >
\\ >> >| ++$hack_count{$1};
\\ >>
\\ >> I recommend using $hack_count{$1}++;
\\ >
\\ > Why?
\\
\\ Post increment is more used, and hence more natural to read.
Huh? Where did this myth come from?
\\ I only use pre
\\ increment when it does matter.
Good for you, but does that mean you have to question someone who uses
pre-increment?
\\ If I see ++$var I wonder what is happening
\\ there.
So, Anno should change his coding style, because of your weakness?
Your statement suggests that you don't wonder if you see '$var++'. I
think you would become a better programmer if your wondering wasn't
asymmetric.
\\ there. Like another example I posted last week somewhere else:
\\
\\ (pseudocode)
\\
\\ i = 0
\\ while (true) {
\\
\\
\\ i++;
\\ last if i >= 10;
\\ }
\\
\\ I consider >= 10 misleading if the previous statement is the only one that
\\ modifies i. It can't get > 10 , so why test for it?
Hah. If I was given a penny for every bug in a program caused by a
programmer "it cannot happen", I could buy Microsoft with my weekly
income.
Abigail
--
perl -we '$@="\145\143\150\157\040\042\112\165\163\164\040\141\156\157\164".
"\150\145\162\040\120\145\162\154\040\110\141\143\153\145\162".
"\042\040\076\040\057\144\145\166\057\164\164\171";`$@`'
------------------------------
Date: 5 Feb 2005 22:01:26 GMT
From: John Bokma <postmaster@castleamber.com>
Subject: Re: perl style: can I combine two steps into one?
Message-Id: <Xns95F4A300FB957castleamber@130.133.1.4>
Rasto Levrinc wrote:
> John Bokma wrote:
>
>> there. Like another example I posted last week somewhere else:
>>
>> (pseudocode)
>>
>> i = 0
>> while (true) {
>>
>>
>> i++;
>> last if i >= 10;
>> }
>>
>> I consider >= 10 misleading if the previous statement is the only one
>> that modifies i. It can't get > 10 , so why test for it?
>
> The reason for that is, that if there is some obscure bug in the code,
> it is less likely, that the program will run in endless loop.
And more likely to move on silently. IMNSHO this is wrong.
> I was
> told so, maybe 10 years ago and I am doing it like this ever since,
> without much thinking about this. But probably it was never needed.
Think again about it, and forgot what someone told to you 10 years ago.
IMNSHO programming to work around mistakes in your code is wrong.
Also, it confuses people. Do you:
a = 10
:
: some code that doesn't do anything with a
:
if ( a != 10 ) a = 10 just in case
I hope not.
--
John Small Perl scripts: http://johnbokma.com/perl/
Perl programmer available: http://castleamber.com/
Happy Customers: http://castleamber.com/testimonials.html
------------------------------
Date: 5 Feb 2005 22:03:45 GMT
From: John Bokma <postmaster@castleamber.com>
Subject: Re: perl style: can I combine two steps into one?
Message-Id: <Xns95F4A3654FB21castleamber@130.133.1.4>
Abigail wrote:
> John Bokma (postmaster@castleamber.com) wrote on MMMMCLXXVI September
> MCMXCIII in <URL:news:Xns95F48D1CD751Bcastleamber@130.133.1.4>:
>][ Anno Siegel wrote:
>][
>][ > sort { $b->[ 1] <=> $a->[ 1] }
>][
>][ BTW, why a space before the 1 and not after? I use for some time a
>]lot of [ white space, ie:
>
>
> The two lines above contain two commas, a question mark and a colon.
> Each of them are followed by space, but not preceeded by any.
>
> Why?
Because it's programmed in English, which has a style guide that recommends
not putting spaces in front of commas, question marks etc.
--
John Small Perl scripts: http://johnbokma.com/perl/
Perl programmer available: http://castleamber.com/
Happy Customers: http://castleamber.com/testimonials.html
------------------------------
Date: 5 Feb 2005 22:09:28 GMT
From: John Bokma <postmaster@castleamber.com>
Subject: Re: perl style: can I combine two steps into one?
Message-Id: <Xns95F4A45DBD13Fcastleamber@130.133.1.4>
Anno Siegel wrote:
> John Bokma <postmaster@castleamber.com> wrote in comp.lang.perl.misc:
>> Anno Siegel wrote:
>>
>> > less of one. The final (top) step is unnecessary and missing now,
>> > so it's only half of a Schwartzian still.
>> >
>> > sort { $b->[ 1] <=> $a->[ 1] }
>> > map [ $_, $hack_count{ $_}],
>> > keys %hack_count;
>>
>> An Artzian transform :-D.
>>
>> BTW, why a space before the 1 and not after? I use for some time a
>> lot of white space, ie:
>>
>> sort { $b->[ 1 ] <=> $a->[ 1 ] }
>> map [ $_, $hack_count{ $_ } ],
>> keys %hack_count;
>>
>> (just curious) I might even line up a bit, e.g.
>
> I lump together closing brackets of all kind, unless I want one to
> stand out. You don't want to miss an opening bracket, but the closing
> ones only confirm what you know. A lump of them can be parsed as
> "this closes everything" (up to a point that can be indicated through
> indentation).
Ok, so the first line should have be:
sort { $b->[ 1] <=> $a->[ 1]}
?
> I have carried this over from Lisp (where it's standard, though with
> only one kind of bracket), but it works with most languages. It is
> also kind of a personal hallmark. I know it is not particularly
> pretty, especially in short bits of code.
I understand the idea, but most editors do bracket matching. And in
cases when it causes problem, I break things a bit more up, for example:
sort {
$b->[ 1 ] <=> $a->[ 1 ]
} map [
$_,
$hack_count{ $_ }
] keys %hack_count;
--
John Small Perl scripts: http://johnbokma.com/perl/
Perl programmer available: http://castleamber.com/
Happy Customers: http://castleamber.com/testimonials.html
------------------------------
Date: 05 Feb 2005 22:10:58 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: perl style: can I combine two steps into one?
Message-Id: <slrnd0ah3i.g2.abigail@alexandra.abigail.nl>
John Bokma (postmaster@castleamber.com) wrote on MMMMCLXXVI September
MCMXCIII in <URL:news:Xns95F4A3654FB21castleamber@130.133.1.4>:
"" Abigail wrote:
""
"" > John Bokma (postmaster@castleamber.com) wrote on MMMMCLXXVI September
"" > MCMXCIII in <URL:news:Xns95F48D1CD751Bcastleamber@130.133.1.4>:
"" >][ Anno Siegel wrote:
"" >][
"" >][ > sort { $b->[ 1] <=> $a->[ 1] }
"" >][
"" >][ BTW, why a space before the 1 and not after? I use for some time a
"" >]lot of [ white space, ie:
"" >
"" >
"" > The two lines above contain two commas, a question mark and a colon.
"" > Each of them are followed by space, but not preceeded by any.
"" >
"" > Why?
""
"" Because it's programmed in English, which has a style guide that recommends
"" not putting spaces in front of commas, question marks etc.
Ah, you mean, space after punctuation, but not before?
Seems like that's happening around the 1s as well.
Or are you claiming there are programming style guides that are universally
accepted?
Abigail
--
perl -weprint\<\<EOT\; -eJust -eanother -ePerl -eHacker -eEOT
------------------------------
Date: 5 Feb 2005 22:23:51 GMT
From: John Bokma <postmaster@castleamber.com>
Subject: Re: perl style: can I combine two steps into one?
Message-Id: <Xns95F4A6CDE9E2Dcastleamber@130.133.1.4>
Abigail wrote:
> So, Anno should change his coding style, because of your weakness?
I took you for a serious person in the past. My weakness I guess.
--
John Small Perl scripts: http://johnbokma.com/perl/
Perl programmer available: http://castleamber.com/
Happy Customers: http://castleamber.com/testimonials.html
------------------------------
Date: 5 Feb 2005 22:24:44 GMT
From: John Bokma <postmaster@castleamber.com>
Subject: Re: perl style: can I combine two steps into one?
Message-Id: <Xns95F4A6F3DB81castleamber@130.133.1.4>
Abigail wrote:
> Or are you claiming there are programming style guides that are
> universally accepted?
Which part of "Why?" did you *not* understand?
--
John Small Perl scripts: http://johnbokma.com/perl/
Perl programmer available: http://castleamber.com/
Happy Customers: http://castleamber.com/testimonials.html
------------------------------
Date: Sat, 05 Feb 2005 23:46:12 +0100
From: Rasto Levrinc <rasto@gmx.at>
Subject: Re: perl style: can I combine two steps into one?
Message-Id: <42054bc2$0$10578$3b214f66@tunews.univie.ac.at>
John Bokma wrote:
> Rasto Levrinc wrote:
>
>
>>John Bokma wrote:
>>
>>
>>>there. Like another example I posted last week somewhere else:
>>>
>>>(pseudocode)
>>>
>>>i = 0
>>>while (true) {
>>>
>>>
>>> i++;
>>> last if i >= 10;
>>>}
>>>
>>>I consider >= 10 misleading if the previous statement is the only one
>>>that modifies i. It can't get > 10 , so why test for it?
>>
>>The reason for that is, that if there is some obscure bug in the code,
>>it is less likely, that the program will run in endless loop.
>
>
> And more likely to move on silently. IMNSHO this is wrong.
>
>
>>I was
>>told so, maybe 10 years ago and I am doing it like this ever since,
>>without much thinking about this. But probably it was never needed.
>
>
> Think again about it, and forgot what someone told to you 10 years ago.
> IMNSHO programming to work around mistakes in your code is wrong.
>
> Also, it confuses people. Do you:
>
> a = 10
> :
> : some code that doesn't do anything with a
> :
> if ( a != 10 ) a = 10 just in case
>
> I hope not.
>
No I don't. But I still think that program, that goes sometimes, maybe
once a year, silently in the endless loop is a little bit worse, than
program that moves on silently with maybe wrong data. You wouldn't like
endless loop in your kernel for example.
It's not that you want to work around your mistakes, there can be many
reasons, why i skips 10.
--
Rasto Levrinc
http://sourceforge.net/projects/rlocate/
------------------------------
Date: 5 Feb 2005 19:41:51 GMT
From: John Bokma <postmaster@castleamber.com>
Subject: Re: Why aren't 'warnings' on by default?
Message-Id: <Xns95F48B558641castleamber@130.133.1.4>
Anno Siegel wrote:
> John Bokma <postmaster@castleamber.com> wrote in comp.lang.perl.misc:
>> Chris Mattern wrote:
>
> [...]
>
>> > there's a lot of old perl code out there written before this,
>> > if you made use warnings the default, that code which had been
>> > running perfectly fine would suddenly start emitting warnings.
>> > This would make a lot of people unhappy...
>>
>> Yup. I have been working 2 years ago on a huge Perl project, and one
>> of the first things I did was turning strict and warnings on.
>>
>> I found quite some weird/bad constructions and actual bugs that way,
>> but it took a lot of time to got it running under strict and
>> warnings.
>
> A general recommendation is to make old code warnings-clean, but not
> to bother with strict "vars" (the hard part of strict). As you have
> observed, it takes a lot of time, and you don't gain very much with a
> program that was written without a view to lexical scope. Variables
> simply won't *have* the small scope they could have, and changing that
> is far from trivial.
Luckly the project was not that bad coded (close: it had a lot of
duplicated code oh, and over 650 (!) modules, and yes, zero
documentation).
> Of course, if the code has a long future ahead it may pay to do the
> necessary partial re-write. Hey, "Refactoring Perl 4 to 5" would
> have been a big success... ten years ago.
:-D. I considered it necessary. I had to start somewhere to clean up the
code, which was needed (probably still is, since I got fired, long
story, not Perl related).
--
John Small Perl scripts: http://johnbokma.com/perl/
Perl programmer available: http://castleamber.com/
Happy Customers: http://castleamber.com/testimonials.html
------------------------------
Date: 5 Feb 2005 20:08:46 GMT
From: John Bokma <postmaster@castleamber.com>
Subject: Re: Why aren't 'warnings' on by default?
Message-Id: <Xns95F48FE711B99castleamber@130.133.1.4>
Peter Wyzl wrote:
> "John Bokma" <postmaster@castleamber.com> wrote in message
> news:Xns95F3F20B3A2F9castleamber@130.133.1.4...
> : Chris Mattern wrote:
> :
> : > Basically, mjl, it's the cause of probably 90% of the evils in
> : > software design: backwards compatibility. -w (the precursor of
> : > use warnings) as we know it today and the restrictions it puts
> : > on your code are relatively recent (of course, in this case
> : > "relatively recent" still means over ten years ago...). Since
> : > there's a lot of old perl code out there written before this,
> : > if you made use warnings the default, that code which had been
> : > running perfectly fine would suddenly start emitting warnings.
> : > This would make a lot of people unhappy...
> :
> : Yup. I have been working 2 years ago on a huge Perl project, and one
> : of
> the
> : first things I did was turning strict and warnings on.
> :
> : I found quite some weird/bad constructions and actual bugs that way,
> : but
> it
> : took a lot of time to got it running under strict and warnings.
>
> First thing I do when looking at someone else's code is turn them both
> on, and look at the resultant errors/warnings.
>
> A recent example is a publicly available 'blogging' script that does
> use 'my' declarations, but inappropriately (ie, declares the same
> variable name three times in the same scope - 'declaraton masks
> earlier in same scope'). That gives some idea about the types of
> problems to be encountered elsewhere. Gives you some idea of what the
> original programmer does or doesn't know.
You aren't talking about GreyMatter are you ? (Yikes)
--
John Small Perl scripts: http://johnbokma.com/perl/
Perl programmer available: http://castleamber.com/
Happy Customers: http://castleamber.com/testimonials.html
------------------------------
Date: 05 Feb 2005 22:02:33 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: Why aren't 'warnings' on by default?
Message-Id: <slrnd0agjo.g2.abigail@alexandra.abigail.nl>
Anno Siegel (anno4000@lublin.zrz.tu-berlin.de) wrote on MMMMCLXXVI
September MCMXCIII in <URL:news:cu2vqg$9m5$1@mamenchi.zrz.TU-Berlin.DE>:
..
.. A general recommendation is to make old code warnings-clean, but not to
.. bother with strict "vars" (the hard part of strict). As you have observed,
.. it takes a lot of time, and you don't gain very much with a program that
.. was written without a view to lexical scope. Variables simply won't *have*
.. the small scope they could have, and changing that is far from trivial.
Well, using strictness doesn't do anything with reducing the scope of
variables. Declaring your variables at the top of the file with 'my'
make strict very very happy - but you still have variables with a broad
scope - and global if you don't use other modules.
Abigail
--
perl -wle '(2 x $_) !~ /^(2|(22+)\2+)$/ && print while ++ $_'
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc. For subscription or unsubscription requests, send
#the single line:
#
# subscribe perl-users
#or:
# unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.
NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
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 7742
***************************************