Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

Obfuscated Code

Name: Anonymous 2009-03-11 20:21

Is it just me or are programmers always trying to use the most obfuscated code possible?

I'm not familiar with other programs, but this routinely seems to be the case with Perl programmers.

I was having some issues with taint mode and went online to search about my particular problem. One person posted this solution:

$string=do_untaint($string);
sub do_untaint {
unless ($string =~ m/^(\w+)$/) { #allow filename to be [a-zA-Z0-9_]
die("Tainted");
} return $1;
}


When he could have simply done:

if($string=~/^(\w+)$/){$string=$1;}

And they both work! Why all the extra shit? And this is just an example,  but I always find ways in which code could be shortened. Am I doing it wrong?

Name: Anonymous 2009-03-11 20:25

>>1
yes, you are doing it very wrong. your code doesn't do the same thing.

Name: Anonymous 2009-03-11 20:35

>>1
His dies when the filename contains illegal characters.  Yours just goes to the next line.

Enjoy your fucked up program.

Name: Anonymous 2009-03-11 20:36

>>2
How not? They're both untainted.

Name: Anonymous 2009-03-11 20:39

if ($title=~/^([0-9]+)$/) {$title=$1;} else {die 'Fuck your shit, nigger';} ?

Name: Anonymous 2009-03-11 20:40

sub unt {if($string=~/^(\w+)$/){return $1;}else{die("Tainted");}}

Name: Anonymous 2009-03-11 20:44

die 'Fuck off, FV.' if $string !~ /^\w+$/;

Name: Anonymous 2009-03-11 20:45

>>7
I chortled.

Name: Anonymous 2009-03-11 20:58

>>3
If the script was in Taint mode, wouldn't it stop running anyways?

Name: Anonymous 2009-03-11 21:02

It's not how I would write it, but that hardly makes it obfuscated.

Name: Anonymous 2009-03-11 21:04

>>1
Please remember that code should be easily understandable to the programmer as well as the computer.

Name: Anonymous 2010-07-21 11:51

TAINT MY ANUS

Name: Anonymous 2010-07-21 12:36

>>9
Taint mode just gives warnings.

Name: Anonymous 2010-12-17 1:33

Xarn is a bad boyfriend

Name: Anonymous 2011-02-04 12:38

Don't change these.
Name: Email:
Entire Thread Thread List