Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: Perl's Bad Ideas

by Dominus (Parson)
on Apr 06, 2002 at 00:53 UTC ( #157095=note: print w/replies, xml ) Need Help??


in reply to Perl's Bad Ideas

My candiates for Perl's Worst Ideas Ever:

3. $/, $\, $", and $,.

Every single function in every single module in the world has to begin with local ($/, $\, $", $,) = ("\n", "", " ", ""); if it wants to be able to print stuff out and actually emit the data it thought it was emitting. Plenty of modules don't do this, and as a result they do something deeply bizarre if you use them in a program that's run with perl -l.

2. open FH, $file instead of $fh = open $file.

Using bareword strings as filehandles was a huge error because it means that filehandles are global variables; it also means that you can't pass them to functions or store them in data structures in a normal way.

Note that changing this would also fix the "comma after filehandle" problem that YuckFoo complains about in another message in this thread, so this problem is a superset of that one.)

1. Implicit conversion of references to strings. Terrible, terrible idea. The 'benefit': It's easy to print out references---which is hardly ever useful anyway. Another 'benefit': You can compare references with eq---but it would have been more efficient to use == instead. The cost: Horrible, horrible bugs where some piece of code goes and silently stores all your data in the array named @{"ARRAY(0x436d1d)"} and then you never find that data again. Or you can use strict 'refs', which means that instead of a silent bug, the program drops dead at run time 1000 lines away from the place that actually committed the error. If references didn't turn into strings in the first place, you wouldn't need strict 'refs' at all; you could throw it away at no cost. (A side benefit might be that people wouldn't be so superstitious about using symbolic references when they were appropriate.)

Perl could have provided a special stringify operator for those rare cases when you wanted to use a reference as a hash key or something. It wouldn't have been hard to provide an extension module to do this.

Compared with these three, I don't think $#array even registers on the scale.

--
Mark Dominus
Perl Paraphernalia

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://157095]
help
Chatterbox?
[Corion]: Hmmm - I thought we'd made the textarea CSS-sized to 100% a long time ago?!
[Corion]: ... nope, it isn't
[LanX]: heh ... 11.78 popes per square mile ...never thought I might find miles handy
[ambrus]: TCLion: it's to make people write non-short writeups in an external editor and save it to a local file. otherwise people will complain that they had a very insightful extended reply but their browser died just when they were almost ready posting it.
[ww]: ++ambrus "their browser died just when...."

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (16)
As of 2017-03-23 18:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should Pluto Get Its Planethood Back?



    Results (292 votes). Check out past polls.