Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Programming Brain-Cramp

by Tuna (Friar)
on Aug 20, 2001 at 07:26 UTC ( #106118=perlmeditation: print w/ replies, xml ) Need Help??

In the spirit of trying to drum up some fun discussion, I ask you the following:

Do you have a particular programming brain-cramp or faux-pax that stands out? Mine, was just this past weekend.

I am in the building a tool based around OpenSSH. So, I have this routine:

my $failedActivation = 0; sub activateFirstCluster { my $offlineStatus; if ($failedActivations eq 3 ) { $offlineStatus = &executeTaskSequence($clusterHost, @offLineSequence +); } else { $command = "/bin/ls"; ($error = &runSystemCommand($command)) && $failedActivations++; print "failed $failedActivations times\n"; return $success; } }
So, as part of my testing, I deliberately injected an error, by specifying $command = " /bin/l ". I was going nuts trying to figure out why my counter wouldn't increment. About an hour or so later, it dawns on me that my system alias for " ls " is " l ".

At the time I thought it was pretty funny. But somebody's gotta have a better one than that.

Comment on Programming Brain-Cramp
Download Code
Re: Programming Brain-Cramp
by blakem (Monsignor) on Aug 20, 2001 at 08:25 UTC
    How about spending an hour debugging a .c file only to realize that your Makefile isn't even pointing at it...
    Doh!

    -Blake

      Allready done! Allways good to hear, that there are other people like me:-)

      Hanamaki
Re: Programming Brain-Cramp
by SparkeyG (Curate) on Aug 20, 2001 at 08:42 UTC
    How's this for you?
    Late night programming back at University, I got the project to compile and respond properly to test data.

    Success thought I. Since the prof took of points for style of code, I figured I would clean up the code... After cleaning up the code, removing debug print statements, renaming varibles from c1 to innerLoopCounter, and the like, the code compiled.
    I turned in the project, took the test, and as I was leaving the TA took me aside and asked why I had turned in a non-working project. I was confused, it worked last night...
    Ended up scouring 2.5kloc for wtf I did wrong when I tried to 'clean up' the code. Ended up I had renamed the same var in two different places. *DOH!!!!*
    The lesson for the day? -- Don't fix, what ain't broken.

    --SparkeyG

      I'd say that the lesson that day was "Use real var names during development"
Re: Programming Brain-Cramp
by maverick (Curate) on Aug 20, 2001 at 09:11 UTC
    Here's one a co-worker of mine ran into the other day
    package Foo; # some code =pod some docs. 1;

    /\/\averick
    perl -l -e "eval pack('h*','072796e6470272f2c5f2c5166756279636b672');"

Re: Programming Brain-Cramp
by mrmick (Curate) on Aug 20, 2001 at 17:51 UTC
    How about using perlcc on a perl program only to find out that, apparently, the inclusion of socket modules generate these types of messages:
    No definition for sub Socket::MSG_EOF (unable to autoload)
    I just came across this last Friday and am still trying to figure it out (or rather, how to fix it).

    ... cramp is still there ... :-)

    Mick
Re: Programming Brain-Cramp
by adamcrussell (Hermit) on Aug 20, 2001 at 20:28 UTC
    My worst experiences have been in the "wrong file" classication.
    In fact, just a couple of days ago I was pulling my hair out wondering why my extensive sendmail.cf changes were not being implemented properly by the sendmail daemon.
    Reason: I was editing the wrong fricking sendmail.cf >:(
Re: Programming Brain-Cramp
by RhetTbull (Curate) on Aug 20, 2001 at 20:31 UTC
    Two things I've done that both drove me nuts. The first was, while editing a C file, I dropped into the shell to do something, got distracted and forgot what I was originally working on so I fired up the editor again, made a couple hours worth of changes then saved and went one my merry way. Later I discovered the original instance of the editor, saved my work (doh!) and exited only to find out I'd wiped out the last couple hours worth of work by saving the old file over the new one!

    The second thing (and sadly this took me two days to discover) was debugging an old Fortran program that dealt with time. I had accidently used the variable "M" as both month and minute. Drove me crazy trying to figure out why the program worked sometimes and not others. I now use very descriptive variable names ;-)

Re: Programming Brain-Cramp
by Maclir (Curate) on Aug 20, 2001 at 20:36 UTC
    Man oh man - where do I begin? In 25 years of programming one accumulates lots of "brain fade" cases. One of the best - and earliest - was berating another IBM OS/370 assembler programmer about his "forgetfullness" in omitting the standard "restore register contents" macro call at the end of a subprogram.

    Then he told me to look at the only executable line in the subroutine - it was a SVC (supervisor call) to generate a system abend - to produce a full core dump when requested. So the routine never even got to return to the calling program.

    Self exits stage left, with a red face.

Re: Programming Brain-Cramp
by dws (Chancellor) on Aug 20, 2001 at 21:58 UTC
    Often, when starting a new job, I've had to dive into poorly structured legacy code. To understand it, I'll take some scenario, and try to trace it through the code. On finding a suspect routine, I used to stop and look for callers, and then backtrack into them. I stopped doing this a couple of years ago after learning that I'd just spent the better part of a week examining unreachable ("oh, we stopped using that stuff a while back") code. Bah!

    Oh, and I get burned by naming a program/script test about once a year. On Unix systems, this can be a momentary heart-stopper.

      That's why I name mine testing.pl ;-)

      RedDog
Re: Programming Brain-Cramp
by dthacker (Deacon) on Aug 21, 2001 at 16:44 UTC
    Wondering why a  split / +/, myfile wasn't working when reading a *.conf file. Seems the file was tab delimited....

    I have so much to learn :)

    Dave

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlmeditation [id://106118]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (5)
As of 2014-12-20 09:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (95 votes), past polls