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 11:44 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 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360