Re: TIMTOWTDI -- so long as it's not my way
by lemming (Priest) on Jan 16, 2001 at 01:58 UTC
|
My most recent was
print printf("%03d\n", $number);
and it took way to long to figure out where the extra
one was coming from.
And another one from a long program that
wrote a bunch of files, but got rid of any empty ones.
# The code as it was executed
open filehandles
print "to file"; # This was anything from
# a few to huge # of items
#cleanup dir
go through directory and unlink any empty files
close filehandles
For some reason if the program didn't have much to say
I'd wind up with fewer files than expected. | [reply] [d/l] [select] |
|
| [reply] [d/l] |
Re: TIMTOWTDI -- so long as it's not my way
by jynx (Priest) on Jan 16, 2001 at 02:11 UTC
|
i think my favorite mistake so far is:
open FILE, $file or die "Couldn't open file: $!";
my @file = <FILE>;
foreach (@file) {
s/ome/substitution/ if ($applicable);
}
close FILE;
i couldn't understand for two days why the output was always a blank file. (i embarassingly had to hand it to a friend for him to notice i wasn't writing the file out! : )
Anyway, ++ Ovid, i fell out of my chair laughing from that code. Thanks for the good cheer.
jynx | [reply] [d/l] |
|
Just telling someone else about a problem is often all you need to realize what the problem (and the solution) is.
/J
| [reply] |
|
A friend of mine called that "The Mannequin Effect" and
just wanted a mannequin to wheel around the office to
people who knew they were doing something stupid, but
couldn't figure out why. That way you wouldn't pull
someone off work just to have you go "Doh!"
| [reply] |
Re: TIMTOWTDI -- so long as it's not my way
by boo_radley (Parson) on Jan 16, 2001 at 02:36 UTC
|
Several dozen instances of
if ($foo =>$bar) {...}
meaning, of course
if ($foo >=$bar) {...}
*sigh* | [reply] [d/l] [select] |
|
Oops. The way to remember that symbol is to remember
that it is called "Greater than or equal to". If you can remember that,
you'll always write >= and never
=>, and then similarly
<= is "Less than or equal to."
Of course, if you're one of those freaks who goes around
saying "equal to or less than", then you're doomed.
| [reply] [d/l] [select] |
Re: TIMTOWTDI -- so long as it's not my way
by danger (Priest) on Jan 16, 2001 at 02:37 UTC
|
print join '|', @array, "\n";
and both times tried to figure out how that empty string got
on the end of my array before coming to my senses.
Update: Oh, and I might as well admit, both times the
statement was a toss-in just to make sure everything was as expected so
far -- go figure :-)
| [reply] [d/l] |
Re: TIMTOWTDI -- so long as it's not my way
by kschwab (Vicar) on Jan 16, 2001 at 03:02 UTC
|
Mmm...I have a perlmonks "doh".
I missed a sleep() here,
which would start an awful busy loop on anyone's server
who took the advice.
To further compound the problem, It looks like I unintentionaly started a flame war with Dominus with a poorly written interpretation of my thoughts.
Hopefully I'll make better use of the preview button
now :)
| [reply] |
|
Syas kschwab:
It looks like I unintentionaly started a flame war
with Dominus with a poorly written interpretation of my thoughts.
If I did anything to give the impression that I
was flaming you, I apologize. I didn't mean to flame.
Besides, as you pointed out, I was mistaken.
I said your loop would always run a million times,
and I was wrong, so it's no wonder that you tried to
find some interpretation of my message that would
have made more sense.
Hopefully I'll make better use of the preview button now :)
Me too.
| [reply] |
|
Heh....
No hard feelings here...you are correct, it wasn't really a flame war.
After looking at your home node, it would appear that I'd be a bit out of my league
if it really was a war :)
| [reply] |
(kudra: Die, Die! DIE!) Re: TIMTOWTDI -- so long as it's not my way
by kudra (Vicar) on Jan 16, 2001 at 14:25 UTC
|
I know that I've done plenty of those doh things myself,
but I seem to have erased them from my memory, so I'll
have to talk about other people's code I've run into at
work ;)
Recently I ran across the efforts of an apparently
homicidal predecessor when I was asked to fix a
project that contained a line that looked a bit like this:
$dbh = DBI->connect("DBI:$dbm:$db:$server", $user, $pwd)
&& die ("Unable to connect to database $db: $DBI::errstr\n");
I might have ruled that an accidental death, but it was
really the start of a rampage. In the project which
consisted of perhaps 10 files, this was done every single
time that 'die' was used.
| [reply] [d/l] |
Re: TIMTOWTDI -- so long as it's not my way
by Dominus (Parson) on Jan 16, 2001 at 11:44 UTC
|
if ($num != 3 || $num != 4) {
# do something
}
...and then wonder why it doesn't do what they wanted.
I'm not sure if it's more embarrassing or less so.
| [reply] [d/l] [select] |
Re: TIMTOWTDI -- so long as it's not my way
by wardk (Deacon) on Jan 16, 2001 at 07:44 UTC
|
my $this = $q->param("this");
if ( $this = "that" ) {
# do something for possibly the wrong reason
}
else {
# not likely
}
| [reply] [d/l] |
Re: TIMTOWTDI -- so long as it's not my way
by cat2014 (Monk) on Jan 16, 2001 at 10:04 UTC
|
one of the worst things that's ever happened to me was learning pascal as my first serious language. to this day, 90% of the time when i want to get the first element
from an array, i automatically type $array[1].
then i spend 3 minutes looking at the funky output, remember that i always screw up arrays, and go fix it. you'd think that after about 2 years of doing this i'd stop.
is there even any other language which uses array[1] instead of array[0] to access the first element?
| [reply] [d/l] [select] |
|
Says cat2014:
is there even any other language which uses array[1]
instead of array[0] to access the
first element?
Fortran.
| [reply] [d/l] [select] |
|
| [reply] |
|
While we're completely off-topic (and no one's around anymore to --me for bringing up this one ; ),
If i remember correctly Ada allows any base for the first element of an array. So you could have an array from 64 to 128 if you wanted.
That would be really confusing if you had different array bounds for every array!
jynx
| [reply] |
|
| [reply] |
|
| temp |
temp := #('one' 'two' 'three').
Transcript show: (temp at: 1).
The line Transcript show: (temp at: 1). will print the string "one".
My training was with C++/C, and on the new job, we get to use Smalltalk. So I've been having the opposite problem that you've been having. :-) | [reply] [d/l] [select] |
|
PostgreSQL is a more contemporary example of something that uses 1-based arrays. Although it's contrary to the concept of relational databases, PostgreSQL lets one define columns that can contain arrays of basic types (like an array of int). These arrays are 1-based.
| [reply] |
(jeffa) Re: TIMTOWTDI -- so long as it's not my way
by jeffa (Bishop) on Jan 17, 2001 at 00:04 UTC
|
A bit late on posting, but since everyone else is being
so honest . . .
Recently I was working on a little code - I took some
lines and made them into a subroutine. Then I did a
test run, and for 10 minutes couldn't figure out that
I forgot to actually call my new subroutine.
And then, just today something like this:
# do section 1 stuff
exit();
# do section 2 stuff
Hmmm, why isn't section 2 executing?
(of course, that exit is harder to see burried in actual code)
Jeff
L-LL-L--L-LL-L--L-LL-L--
-R--R-RR-R--R-RR-R--R-RR
F--F--F--F--F--F--F--F--
(the triplet paradiddle)
| [reply] [d/l] |
Re: TIMTOWTDI -- so long as it's not my way
by jepri (Parson) on Jan 16, 2001 at 09:48 UTC
|
Yup. Even worse, I posted this in the chatbox and asked why it wasn't working:
my $thing;
while $something (@somethingelse) {
my $thing;
....;
print $thing;
}
At first I couldn't understand why it was overwriting $thing, then I asked the CB why I wasn't getting a warning for overriding $thing. That was a bad code day. :)____________________
Jeremy
I didn't believe in evil until I dated it. | [reply] [d/l] |
Re: TIMTOWTDI -- so long as it's not my way
by radagast (Sexton) on Jan 19, 2001 at 16:40 UTC
|
Here are a couple of enormously annoying mistakes. First, as my background before Perl (B.P.?) was C/C++, I always had fun forgetting to prefix my variables with $ or better yet, getting careless with Perl's flexibility and not initializing some variables before they were used.
Second, this is more to do with the keyboard I use but it affects most of my work which is in Perl. I have a British keyboard and the British Pound happens to be next to the $ and occasionally my finger slips. Through telnet, I was always accidently placing pounds and whenever the scripts executed, I always got something along the lines of '\024 not found'. The pound never showed up. Only by using a windows program, UltraEdit, did I catch the mistake. Hugely embarrasing.
---
"I slept with Faith, and found a corpse in my arms on awaking; I drank and danced all night with Doubt, and found her a virgin in the morning."
Aleister Crowley, _The Book of Lies_
| [reply] |
q(),qq(),qw(),qx()...AARGH!
by Madams (Pilgrim) on Mar 17, 2001 at 06:05 UTC
|
#/usr/bin/perl -w
use strict;
#much other stuff....
#initializations etc....
foreach $file (@list_of_filenames){
open(THISFILE,'< $file') or warn "ERROR: Can't open $file!\n";#for
+ this application fail to open is not fatal..
binmode(THISFILE);
$data = Digest::MD5->new->addfile(*THISFILE)->hexdigest;
return unless ($data);
#...process $data.....
}
Gee, why does every file have the same digest?....
Maybe because open tries to open a file NAMED: " < $file " ?
I keep tripping on the q() vs qq() vs qw() vs qx() differences....
_________________
madams@scc.net
(__)
(\/)
/-------\/
/ | 666 ||
* ||----||
| [reply] [d/l] [select] |
Re: TIMTOWTDI -- so long as it's not my way
by turnstep (Parson) on Jan 16, 2001 at 18:52 UTC
|
I recently could not sleep and decided to do some coding
(anyone else do that?) and deep in the bowels of my
program came up with this gem:
seek(FOOBAR, 2, 0);
This appeared right before I was to write information
(e.g. append) to the end of a file. Needless to say,
the error was discovered very quickly! Luckily, I had
a backup of the file in question. :)
| [reply] [d/l] |
Re: TIMTOWTDI -- so long as it's not my way
by TGI (Parson) on Jan 17, 2001 at 00:11 UTC
|
The error I make, over and over, is putting a semicolon where it doesn't belong.
sub foo ($$);
{ while ($bar);
{ $bar = 0;
print << "HERE_DOC";
This doesn't print for some reason
HERE_DOC
}
}
I'm finally starting to recognize the various errors this generates. At this rate I'll only need to repeat this error about a thousand more times.
TGI says moo | [reply] [d/l] |
Re: TIMTOWTDI -- so long as it's not my way
by EvanK (Chaplain) on Jan 17, 2001 at 00:19 UTC
|
For 3 days I couldnt figure this one out...
open(FILE,"...");
format =
blah
.
write;
close(FILE);
______________________________________________
When I get a little money, I buy books. If I have any left over, I buy food and clothes.
-Erasmus
| [reply] [d/l] |
|
| [reply] [d/l] |
Re: TIMTOWTDI -- so long as it's not my way
by leons (Pilgrim) on Jan 18, 2001 at 14:30 UTC
|
Okay .... I have just been staring at the following for over an hour ...
Being totally amazed by the fact that it returned an Odd number of elements
in hash assignment Okay ... stuff like that happens ... stuff like that happens
a lot ;-) but the frustrating part is that, I made the same mistake a week ago as
well and then it took me the whole morning .. hmmm ... I think I'm going to have
another cup of coffee ;-)
sub MySub
{
my (%Information,@Errors);
# blah blah
push @Errors,"an Error occured\n" if $whatever;
return(\%Information,\@Errors);
}
my ($InformationRef,$ErrorsRef)=MySub;
my (%Information,@Errors)=(%{$InformationRef},@{$ErrorsRef}); # !!!
| [reply] [d/l] |
Re: TIMTOWTDI -- so long as it's not my way
by Elgon (Curate) on Jan 16, 2001 at 23:07 UTC
|
Oooh, getting lots of replies on this one: I think the problem is when you focus too much on the form of the code and not what you are actually trying to achieve. I have written some (rarely, I admit) lovely code but when I try it I am horrified when it doesn't work.
Later, usually after a nicoteine and Dr.Pepper fix, when I look at it again I suddenly notice the truth:
There is no problem with the code. Instead, try to realise that the problem is not in the code but... Thinks: I've still not got the Matrix out of my system... comes from your assumptions that you have built into the code.
I do like the
if ($foo = $bar && $foo != $bar)
{
#code
}
though, it's a nice cockup.
Elgon | [reply] [d/l] |