Tilted Forum Project Discussion Community  

Go Back   Tilted Forum Project Discussion Community > Interests > Tilted Technology


 
 
LinkBack Thread Tools
Old 10-13-2003, 10:56 AM   #1 (permalink)
Darth Papa
 
ratbastid's Avatar
 
Location: Yonder
Tiny mistake, BIG problem

Just in case any of you were wondering, when you're working in Perl, building a select box of shipping rates, there's a HUGE difference between this:

<code>
foreach my $key (sort {$rates->{$a} <=> $rates->{$b}} keys %$rates) {
&nbsp;&nbsp;$option_list .= '&lt;option value="' . $ups->servicenames($key) . $rates->{$key} . "\">$key - $rates->{$key}</option>\n";
}
</code>


And:<code>
foreach my $key (sort {$rates->{$a} <=> $rates->{$b}} keys %$rates) {
&nbsp;&nbsp;$option_list .= '&lt;option value="' . $ups->servicenames($key) . $rates->{$key} "\">$key - $rates->{$key}</option>\n";
}
</code>

One dot makes all the difference between "runs" and "not runs". That dot is the difference between "happy customer" and "SAD customer".

What obnoxious little spelling errors have YOU programmed recently?
ratbastid is offline  
Old 10-13-2003, 03:11 PM   #2 (permalink)
Junkie
 
Location: RI
Lets see...I think I missed a " somewhere and I spent three hours searching a 5k line file for where the error was. That I think was my most recent
Fallon is offline  
Old 10-13-2003, 04:11 PM   #3 (permalink)
The GrandDaddy of them all!
 
The_Dude's Avatar
 
Location: Austin, TX
Quote:
int x = (int)(Math.Random() * 3)+1;
i was like why wasnt it workin, then i realized that "Random" shouldnt start w/ a capital letter.

case sensitive bastards.
__________________
"Luck is what happens when preparation meets opportunity." - Darrel K Royal
The_Dude is offline  
Old 10-13-2003, 04:22 PM   #4 (permalink)
Banned
 
Location: shittown, CA
Quote:
Originally posted by The_Dude
case sensitive bastards.
Welcome to the wide world of programming.
juanvaldes is offline  
Old 10-13-2003, 04:27 PM   #5 (permalink)
Junkie
 
Programmers scare me.

I don't have a very "structured" mind that can look at things in a "logical" manner. My mind is all over the place, jumping from topic to topic, trying to understand the Big Picture etc.

Makes me a good PM, but I would be crap at programming...


Mr Mephisto
Mephisto2 is offline  
Old 10-13-2003, 05:35 PM   #6 (permalink)
Darth Papa
 
ratbastid's Avatar
 
Location: Yonder
Quote:
Originally posted by The_Dude
case sensitive bastards.
Yeah. They're also real shits when it comes to spelling. Picky, picky!

Okay, so "print" isn't spelled with a "g" on the end. You knew what I MEANT!!!
ratbastid is offline  
Old 10-13-2003, 07:45 PM   #7 (permalink)
Huggles, sir?
 
seretogis's Avatar
 
Location: Seattle
Oh man. You have no idea how wonderful that syntax highlighting in vim is until you try to work without it. I used to find it irritating to begin with, but now I can't work without it.
__________________
seretogis - sieg heil
perfect little dream the kind that hurts the most, forgot how it feels well almost
no one to blame always the same, open my eyes wake up in flames
seretogis is offline  
Old 10-13-2003, 11:57 PM   #8 (permalink)
Rookie
 
cliche's Avatar
 
Location: Oxford, UK
I still have a habit of leaving out semicolons, which always seems to throw up random entertaining errors.
__________________
I can't understand why people are frightened of new ideas. I'm frightened of the old ones. -- John Cage (1912 - 1992)
cliche is offline  
Old 10-14-2003, 12:14 AM   #9 (permalink)
paranoid
 
Silvy's Avatar
 
Location: The Netherlands
Debugging?
Try any program in Miranda...
It keeps throwing up errors like
Code:
type [[[[[[[[]]]]]]]] is unequal to [[[[[[[]]]]]]]
Tiny source, easy problem, but reading the error... sheesh!
__________________
"Do not kill. Do not rape. Do not steal. These are principles which every man of every faith can embrace. "
- Murphy MacManus (Boondock Saints)
Silvy is offline  
Old 10-14-2003, 01:20 AM   #10 (permalink)
Cracking the Whip
 
Lebell's Avatar
 
Location: Sexymama's arms...
O vs 0.

I spent a day tearing out my hair (much thicker then) over this one.
__________________
"Of all tyrannies, a tyranny exercised for the good of its victims may be the most oppressive. It may be better to live under robber barons than under omnipotent moral busybodies. The robber baron's cruelty may sometimes sleep, his cupidity may at some point be satiated; but those who torment us for our own good will torment us without end, for they do so with the approval of their own conscience." – C. S. Lewis

The ONLY sponsors we have are YOU!

Please Donate!
Lebell is offline  
Old 10-14-2003, 04:12 AM   #11 (permalink)
Huggles, sir?
 
seretogis's Avatar
 
Location: Seattle
Quote:
Originally posted by Lebell
O vs 0.

I spent a day tearing out my hair (much thicker then) over this one.
Ouch! May I suggest changing fonts?
__________________
seretogis - sieg heil
perfect little dream the kind that hurts the most, forgot how it feels well almost
no one to blame always the same, open my eyes wake up in flames
seretogis is offline  
Old 10-14-2003, 05:07 AM   #12 (permalink)
Crazy
 
Location: Reading, UK
Re: Tiny mistake, BIG problem

Mine wasn't really a spelling error. But I started crying when after 2 days of debugging and no sleeping I finally found the "//FJD" remark in the code. (Just For Debug).
After removing couple of lines after the remark everything worked like a charm...

Quote:
Originally posted by ratbastid
<code>
foreach my $key (sort {$rates->{$a} <=> $rates->{$b}} keys %$rates) {
&nbsp;&nbsp;$option_list .= '&lt;option value="' . $ups->servicenames($key) . $rates->{$key} "\">$key - $rates->{$key}</option>\n";
}
</code>
A remark about the perl code:
In the "foreach" line when you use the when you use "keys" it's not necessary to write %$. The % is enough. Like this:
<code>
foreach my $key (sort {$rates->{$a} <=> $rates->{$b}} keys %rates)
</code>
peacy is offline  
Old 10-14-2003, 05:29 AM   #13 (permalink)
Darth Papa
 
ratbastid's Avatar
 
Location: Yonder
Quote:
Originally posted by peacy
A remark about the perl code:
In the "foreach" line when you use the when you use "keys" it's not necessary to write %$. The % is enough. Like this:
<code>
foreach my $key (sort {$rates->{$a} <=> $rates->{$b}} keys %rates)
</code>
Not when you're working with a hashref, it's not. The hash reference $rates must be "hashified" by spelling it %$rates as an argument to the keys() function. Otherwise you're talking about the HASH %rates which, in this code snippet, is undefined.

Try running the following code:

Code:
#!/usr/bin/perl

my $hashref;
my %hash;

%hash = ( a => 1, b => 2);
$hashref = \%hash;

print "Foreaching through \%hash:\n";
foreach my $key (keys %hash) {
&nbsp;&nbsp;print "$key -> $hash{$key}\n";
}

print "\nForeaching through \$hashref:\n";
foreach $key (keys %$hashref) {
&nbsp;&nbsp;print "$key -> $hashref->{$key}\n";
}

print "\nForeaching through \$hashref treated like a hash:\n";
foreach $key (keys %hashref) {
&nbsp;&nbsp;print "$key -> $hashref->{$key}\n";
}

print "\nDone!\n";
exit(0);
This is ANOTHER thing I've learned by making stupid one-character mistakes!
ratbastid is offline  
Old 10-14-2003, 05:35 AM   #14 (permalink)
Crazy
 
Location: Reading, UK
Quote:
Originally posted by ratbastid
Not when you're working with a hashref, it's not. The hash reference $rates must be "hashified" by spelling it %$rates as an argument to the keys() function. Otherwise you're talking about the HASH %rates which, in this code snippet, is undefined.
Ok... From the original code I didn't realize (at first sight) that it's a ref... Should've known it...
peacy is offline  
 

Tags
big, mistake, problem, tiny


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -8. The time now is 07:10 PM.

Tilted Forum Project

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Search Engine Optimization by vBSEO 3.6.0 PL2
© 2002-2012 Tilted Forum Project

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62