Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

Re: Stupid mistakes I repeatedly make

by DrWhy (Chaplain)
on Mar 28, 2005 at 15:19 UTC ( #442831=note: print w/replies, xml ) Need Help??

in reply to Stupid mistakes I repeatedly make

I rarely make any of these mistakes, although I've done the first kind of thing with chomp a bunch of times. (my @chomparr = map chomp, @rawarray; my solution to this has been, just to accept chomp in place: chomp for @array. Here are some of my favorite mistakes:

I'm always leaving out semicolons in random places where they are required. This has gotten worse lately as I have been switching back and forth between Perl and Python alot.

As others have mentioned in this thread, leaving out a closing brace (or having an extraneous open brace) can be a pain to track down since Perl's error output on this one is not optimally helpful. I sometimes have to take a binary approach to finding the problem. Start by sticking a __END__ in about the middle of the code. If you still get this error move the __END__ to about 3/4ths of the way down. If you don't, move it up to the 1/4 position. And so on.

use Data::Dumper warn Dumper($var);
This is really just a variation on the ';' issue above but I do it so often it deserves its own listing.

sub mysub($a) {my ($a) = @_; ...}
This is another case of Python poisoning.

if $this eq $that {do something}
Parentheses are optional so many places that I (or at least my fingers) forget where they are required.

use Module qw( $a, $b, $c )
'Fortunately' this usually causes a compile error or at least a warning with -w, so I catch this quickly.


"If God had meant for us to think for ourselves he would have given us brains. Oh, wait..."

Replies are listed 'Best First'.
Re^2: Stupid mistakes I repeatedly make
by dragonchild (Archbishop) on Mar 28, 2005 at 15:40 UTC
    I'm starting to notice something similar now that I've been doing more Javascript programming. For example, the dot-notation for objects/references is really taking over my finger memory. The lack of sigils in Javascript is messing me up, as well, when I return to the Mothership.

    I notice it again when moving back and forth between gvim and textareas in browsers. 0wc newtext[ESC] doesn't seem to work in Firefox ...

    Being right, does not endow the right to be rude; politeness costs nothing.
    Being unknowing, is not the same as being stupid.
    Expressing a contrary opinion, whether to the individual or the group, is more often a sign of deeper thought than of cantankerous belligerence.
    Do not mistake your goals as the only goals; your opinion as the only opinion; your confidence as correctness. Saying you know better is not the same as explaining you know better.

      When it comes to sigils I'm doing the oposite. I keep using them in my JavaScript and VB. And often even adding ; at the end of lines of the VB code.

      Maybe it's because I spend most time with Perl and MS SQL, both using sigils for their variables.

      We'd like to help you learn to help yourself
      Look around you, all you see are sympathetic eyes
      Stroll around the grounds until you feel at home
         -- P. Simon in Mrs. Robinson

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://442831]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (7)
As of 2021-04-23 13:10 GMT
Find Nodes?
    Voting Booth?

    No recent polls found