- 1
- 2
my ($new_framed_ip) = @actets[0]."."1".".@actets[2].".".@actets[3];
$framed_ip = $new_framed_ip;
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
−146
my ($new_framed_ip) = @actets[0]."."1".".@actets[2].".".@actets[3];
$framed_ip = $new_framed_ip;
−218
for ($i=1;$i++;$i<=$r) {
print qq~</div>~;
}
Перепутал местами...
−255.6
sub player_win{
my $self = shift;
my ($T, $U) = @_;
my $H = $self->file_to_hash($T);
my $WIN = 0;
my ($i, $k, $c, $z) = (0, 0, 0, 0);
if( $T->{_MAX_COUNT} == 32 ){
for($i = 0; $i < 2; $i++){
for($k = 0; $k < 2; $k++){
for($c = 0; $c < 2; $c++){
for($z = 0; $z < 2; $z++){
foreach(0..1){
if($H->{data}->{grid}->{f1}->{f2}[$i]->{f4}[$k]->{f8}[$c]->{f16}[$z]->{ppl}[$_]->{id} == $U->{_ID}){
if($H->{data}->{grid}->{f1}->{f2}[$i]->{f4}[$k]->{f8}[$c]->{f16}[$z]->{id} == 0){
$H->{data}->{grid}->{f1}->{f2}[$i]->{f4}[$k]->{f8}[$c]->{f16}[$z]->{id} = $U->{_ID};
$WIN = $H->{data}->{grid}->{f1}->{f2}[$i]->{f4}[$k]->{f8}[$c]->{f16}[0]->{id} if $z == 1;
$WIN = $H->{data}->{grid}->{f1}->{f2}[$i]->{f4}[$k]->{f8}[$c]->{f16}[1]->{id} if $z == 0;
} elsif($H->{data}->{grid}->{f1}->{f2}[$i]->{f4}[$k]->{f8}[$c]->{id} == 0){
$H->{data}->{grid}->{f1}->{f2}[$i]->{f4}[$k]->{f8}[$c]->{id} = $U->{_ID};
$WIN = $H->{data}->{grid}->{f1}->{f2}[$i]->{f4}[$k]->{f8}[0]->{id} if $c == 1;
$WIN = $H->{data}->{grid}->{f1}->{f2}[$i]->{f4}[$k]->{f8}[1]->{id} if $c == 0;
} elsif ($H->{data}->{grid}->{f1}->{f2}[$i]->{f4}[$k]->{id} == 0){
$H->{data}->{grid}->{f1}->{f2}[$i]->{f4}[$k]->{id} = $U->{_ID};
$WIN = $H->{data}->{grid}->{f1}->{f2}[$i]->{f4}[0]->{id} if $k == 1;
$WIN = $H->{data}->{grid}->{f1}->{f2}[$i]->{f4}[1]->{id} if $k == 0;
} elsif ($H->{data}->{grid}->{f1}->{f2}[$i]->{id} == 0){
$H->{data}->{grid}->{f1}->{f2}[$i]->{id} = $U->{_ID};
$WIN = $H->{data}->{grid}->{f1}->{f2}[0]->{id} if $i == 1;
$WIN = $H->{data}->{grid}->{f1}->{f2}[1]->{id} if $i == 0;
} elsif ($H->{data}->{grid}->{f1}->{id} == 0){
$H->{data}->{grid}->{f1}->{id} = $U->{_ID};
$WIN = -1;
}
}
}
}
}
}
}
} elsif( $T->{_MAX_COUNT} == 16 ){
for($i = 0; $i < 2; $i++){
for($k = 0; $k < 2; $k++){
for($c = 0; $c < 2; $c++){
foreach(0..1){
if($H->{data}->{grid}->{f1}->{f2}[$c]->{f4}[$k]->{f8}[$i]->{ppl}[$_]->{id} == $U->{_ID}){
if($H->{data}->{grid}->{f1}->{f2}[$c]->{f4}[$k]->{f8}[$i]->{id} == 0){
$H->{data}->{grid}->{f1}->{f2}[$c]->{f4}[$k]->{f8}[$i]->{id} = $U->{_ID};
$WIN = $H->{data}->{grid}->{f1}->{f2}[$c]->{f4}[$k]->{f8}[0]->{id} if $i == 1;
$WIN = $H->{data}->{grid}->{f1}->{f2}[$c]->{f4}[$k]->{f8}[1]->{id} if $i == 0;
} elsif ($H->{data}->{grid}->{f1}->{f2}[$c]->{f4}[$k]->{id} == 0){
$H->{data}->{grid}->{f1}->{f2}[$c]->{f4}[$k]->{id} = $U->{_ID};
$WIN = $H->{data}->{grid}->{f1}->{f2}[$c]->{f4}[0]->{id} if $k == 1;
$WIN = $H->{data}->{grid}->{f1}->{f2}[$c]->{f4}[1]->{id} if $k == 0;
} elsif ($H->{data}->{grid}->{f1}->{f2}[$c]->{id} == 0){
$H->{data}->{grid}->{f1}->{f2}[$c]->{id} = $U->{_ID};
$WIN = $H->{data}->{grid}->{f1}->{f2}[0]->{id} if $c == 1;
$WIN = $H->{data}->{grid}->{f1}->{f2}[1]->{id} if $c == 0;
} elsif ($H->{data}->{grid}->{f1}->{id} == 0){
$H->{data}->{grid}->{f1}->{id} = $U->{_ID};
$WIN = -1;
}
}
}
}
}
}
} elsif($T->{_MAX_COUNT} == 8){
for($k = 0; $k < 2; $k++){
for($c = 0; $c < 2; $c++){
foreach(0..1){
if($H->{data}->{grid}->{f1}->{f2}[$c]->{f4}[$k]->{ppl}[$_]->{id} == $U->{_ID}){
if($H->{data}->{grid}->{f1}->{f2}[$c]->{f4}[$k]->{id} == 0){
$H->{data}->{grid}->{f1}->{f2}[$c]->{f4}[$k]->{id} = $U->{_ID};
$WIN = $H->{data}->{grid}->{f1}->{f2}[$c]->{f4}[0]->{id} if $k == 1;
$WIN = $H->{data}->{grid}->{f1}->{f2}[$c]->{f4}[1]->{id} if $k == 0;
} elsif ($H->{data}->{grid}->{f1}->{f2}[$c]->{id} == 0){
$H->{data}->{grid}->{f1}->{f2}[$c]->{id} = $U->{_ID};
$WIN = $H->{data}->{grid}->{f1}->{f2}[0]->{id} if $c == 1;
$WIN = $H->{data}->{grid}->{f1}->{f2}[1]->{id} if $c == 0;
} elsif ($H->{data}->{grid}->{f1}->{id} == 0){
$H->{data}->{grid}->{f1}->{id} = $U->{_ID};
$WIN = -1;
}
}
}
}
}
} elsif($T->{_MAX_COUNT} == 4){
for($c = 0; $c < 2; $c++){
foreach(0..1){
if($H->{data}->{grid}->{f1}->{f2}[$c]->{ppl}[$_]->{id} == $U->{_ID}){
if($H->{data}->{grid}->{f1}->{f2}[$c]->{id} == 0){
$H->{data}->{grid}->{f1}->{f2}[$c]->{id} = $U->{_ID};
$WIN = $H->{data}->{grid}->{f1}->{f2}[0]->{id} if $c == 1;
$WIN = $H->{data}->{grid}->{f1}->{f2}[1]->{id} if $c == 0;
} elsif ($H->{data}->{grid}->{f1}->{id} == 0){
$H->{data}->{grid}->{f1}->{id} = $U->{_ID};
$WIN = -1;
}
}
Очень "гибкий" алгоритм.
−305.1
my ($_bonus1_l, $_bonus1_y, $_bonus2_l, $_bonus2_y) = ($l1*10 > rand(100) ? 1 : 0, $y1*10 > rand(100) ? 1 : 0, $l2*10 > rand(100) ? 1 : 0, $y2*10 > rand(100) ? 1 : 0);
($_bonus1_l, $_bonus2_l) = (0, 0) if $_bonus1_l == 1 and $_bonus2_l == 1;
($_bonus1_y, $_bonus2_y) = (0, 0) if $_bonus1_y == 1 and $_bonus2_y == 1;
if($turn > 12){
my ($_a1_def, $_b1_def, $_c1_def) = mass($pl1_mov, $User1, "def");
my ($_a1_att, $_b1_att, $_c1_att) = mass($pl1_att, $User1, "att");
my ($_a2_def, $_b2_def, $_c2_def) = mass($pl2_mov, $User2, "def");
my ($_a2_att, $_b2_att, $_c2_att) = mass($pl2_att, $User2, "att");
$N1 += $_a1_att if $_a2_def < 1000000;
$N1 += $_b1_att if $_b2_def < 1000000;
$N1 += $_c1_att if $_c2_def < 1000000;
$N2 += $_a2_att if $_a1_def < 1000000;
$N2 += $_b2_att if $_b1_def < 1000000;
$N2 += $_c2_att if $_c1_def < 1000000;
if($_bonus1_l){
my $l = int(rand(3));
## сБНПНР
if($l == 0){
my $r = 0;
($_a2_att, $r) = (0, 1) if $_a2_att > 0 and $_a1_def < 1000000;
($_b2_att, $r) = (0, 1) if $_b2_att > 0 and $_a1_def < 1000000 and $r == 0;
($_c2_att, $r) = (0, 1) if $_c2_att > 0 and $_a1_def < 1000000 and $r == 0;
$U1 = $r;
} elsif($l == 1){
my $r = 0;
($_a1_att, $r, $K2) = (int($_a1_att * 1.5), 1, int($_a1_att/2)) if $_a1_att > 0 and $_a2_def < 1000000;
($_b1_att, $r, $K2) = (int($_b1_att * 1.5), 1, int($_b1_att/2)) if $_b1_att > 0 and $_b2_def < 1000000 and $r == 0;
($_c1_att, $r, $K2) = (int($_c1_att * 1.5), 1, int($_c1_att/2)) if $_c1_att > 0 and $_c2_def < 1000000 and $r == 0;
} elsif($l == 2){
my ($r, $ov, $v) = (0, 0, int(rand(3)));
($_a1_att, $r, $ov) = (0, 1, (int($_a2_att/2))) if $_a2_att > 0 and $_a1_def > 1000000;
($_b1_att, $r, $ov) = (0, 1, (int($_b2_att/2))) if $_b2_att > 0 and $_b1_def > 1000000 and $r == 0;
($_c1_att, $r, $ov) = (0, 1, (int($_c2_att/2))) if $_c2_att > 0 and $_c1_def > 1000000 and $r == 0;
$_a1_att += $ov if $v == 0;
$_b1_att += $ov if $v == 1;
$_c1_att += $ov if $v == 2;
$O1 = $ov;
}
}
if($_bonus2_l){
my $l = int(rand(100));
if($l == 0){
my $r = 0;
($_a1_att, $r) = (0, 1) if $_a1_att > 0 and $_a2_def < 1000000;
($_b1_att, $r) = (0, 1) if $_b1_att > 0 and $_a2_def < 1000000 and $r == 0;
($_c1_att, $r) = (0, 1) if $_c1_att > 0 and $_a2_def < 1000000 and $r == 0;
$U2 = $r;
} elsif($l == 1){
my $r = 0;
($_a2_att, $r, $K1) = (int($_a2_att * 1.5), 1, int($_a2_att/2)) if $_a2_att > 0 and $_a1_def < 1000000;
($_b2_att, $r, $K1) = (int($_b2_att * 1.5), 1, int($_b2_att/2)) if $_b2_att > 0 and $_b1_def < 1000000 and $r == 0;
($_c2_att, $r, $K1) = (int($_c2_att * 1.5), 1, int($_c2_att/2)) if $_c2_att > 0 and $_c1_def < 1000000 and $r == 0;
} elsif($l == 2){
my ($r, $ov, $v) = (0, 0, int(rand(3)));
($_a2_att, $r, $ov) = (0, 1, (int($_a1_att/2))) if $_a1_att > 0 and $_a2_def > 1000000;
($_b2_att, $r, $ov) = (0, 1, (int($_b1_att/2))) if $_b1_att > 0 and $_b2_def > 1000000 and $r == 0;
($_c2_att, $r, $ov) = (0, 1, (int($_c1_att/2))) if $_c1_att > 0 and $_c2_def > 1000000 and $r == 0;
$_a2_att += $ov if $v == 0;
$_b2_att += $ov if $v == 1;
$_c2_att += $ov if $v == 2;
$O2 = $ov;
}
}
if($_bonus1_y){
my $l = int(rand(2));
if($l == 0){
my ($r, $rik, $V1) = (0, 0, int(rand(3)) + 1);
($r, $rik) = (1, (int($_a1_att/2))) if $_a1_att > 0 and $_a2_def < 1000000 and $V1 == 1;
($r, $rik) = (1, (int($_b1_att/2))) if $_b1_att > 0 and $_b2_def < 1000000 and $r == 0 and $V1 == 2;
($r, $rik) = (1, (int($_c1_att/2))) if $_c1_att > 0 and $_c2_def < 1000000 and $r == 0 and $V1 == 3;
$R2 = $rik;
$db->query("UPDATE duel set pl1_rik = CONCAT(pl1_rik, $V1) where sid = \"$dsid\"") if $R2 > 0;
} elsif($l == 1){
my $r = 0;
($_a2_def, $r) = ($_a2_def - 1000000, 1) if $_a1_att > 0 and $_a2_def > 1000000;
($_b2_def, $r) = ($_b2_def - 1000000, 2) if $_b1_att > 0 and $_b2_def > 1000000 and $r == 0;
($_c2_def, $r) = ($_c2_def - 1000000, 3) if $_c1_att > 0 and $_c2_def > 1000000 and $r == 0;
$T2 = $r;
}
}
if($_bonus2_y){
my $l = int(rand(2));
if($l == 0){
my ($r, $rik, $V2) = (0, 0, int(rand(3)) + 1);
($r, $rik) = (1, (int($_a2_att/2))) if $_a2_att > 0 and $_a1_def < 1000000 and $V2 == 1;
($r, $rik) = (1, (int($_b2_att/2))) if $_b2_att > 0 and $_b1_def < 1000000 and $r == 0 and $V2 == 2;
($r, $rik) = (1, (int($_c2_att/2))) if $_c2_att > 0 and $_c1_def < 1000000 and $r == 0 and $V2 == 3;
#$_a2_att += $rik if $V2 == 1;
#$_b2_att += $rik if $V2 == 2;
#$_c2_att += $rik if $V2 == 3;
$R1 = $rik;
$db->query("UPDATE duel set pl2_rik = CONCAT(pl2_rik, $V2) where sid = \"$dsid\"") if $R1 > 0;
} elsif($l == 1){
my $r = 0;
($_a1_def, $r) = ($_a1_def - 1000000, 1) if $_a2_att > 0 and $_a1_def > 1000000;
($_b1_def, $r) = ($_b1_def - 1000000, 2) if $_b2_att > 0 and $_b1_def > 1000000 and $r == 0;
Из браузерной игрушки на mod_perl/mysql. Код наглядно демонстрирует, что говнокод зависит не от языка, а от программиста.
−307.7
sub get_ppl{
my $self = shift;
my ($U, $print_done, $team) = @_;
return "<ppl team_id='$team' battle_stats='$U->{_CHAR}->{win},$U->{_CHAR}->{loose},$U->{_CHAR}->{nobody}' medals='".$U->get_medal_string_for_user($U)."' $clan team_id='0' av_id='$U->{_CHAR}->{av_id}' fn='$U->{_CHAR}->{avatara}' u='$U->{_CHAR}->{u}' hp_u='$U->{_CHAR}->{hp_u}' stat0_u='$U->{_CHAR}->{stat0_u}' stat0='$U->{_CHAR}->{f}' stat1='$U->{_CHAR}->{m}' stat2='$U->{_CHAR}->{y}' stat3='$U->{_CHAR}->{l}' hpmax='$U->{_CHAR}->{maxhp}' hp='$U->{_CHAR}->{hp}' aname='$U->{_USER_NAME}' lvl='$U->{_CHAR}->{lvl}' cname='$U->{_CHAR}->{name}' id='$U->{_ID}' carma='$U->{_CHAR}->{carma}' sex='$U->{_CHAR}->{sex}' slot0='$Item[0]' slot8='$Item[8]' slot7='$Item[7]' slot6='$Item[6]' slot1='$Item[1]' weight='$U->{_CHAR}->{weight}' slot5='$Item[5]' slot4='$Item[4]' slot3='$Item[3]' slot2='$Item[2]' city_id='$U->{_CHAR}->{city_id}'/>" if !$print_done;
return "<ppl done='true' battle_stats='$U->{_CHAR}->{win},$U->{_CHAR}->{loose},$U->{_CHAR}->{nobody}' medals='".$U->get_medal_string_for_user($U)."' $clan team_id='0' av_id='$U->{_CHAR}->{av_id}' fn='$U->{_CHAR}->{avatara}' u='$U->{_CHAR}->{u}' hp_u='$U->{_CHAR}->{hp_u}' stat0_u='$U->{_CHAR}->{stat0_u}' stat0='$U->{_CHAR}->{f}' stat1='$U->{_CHAR}->{m}' stat2='$U->{_CHAR}->{y}' stat3='$U->{_CHAR}->{l}' hpmax='$U->{_CHAR}->{maxhp}' hp='$U->{_CHAR}->{hp}' aname='$U->{_USER_NAME}' lvl='$U->{_CHAR}->{lvl}' cname='$U->{_CHAR}->{name}' id='$U->{_ID}' carma='$U->{_CHAR}->{carma}' sex='$U->{_CHAR}->{sex}' slot0='$Item[0]' slot8='$Item[8]' slot7='$Item[7]' slot6='$Item[6]' slot1='$Item[1]' weight='$U->{_CHAR}->{weight}' slot5='$Item[5]' slot4='$Item[4]' slot3='$Item[3]' slot2='$Item[2]' city_id='$U->{_CHAR}->{city_id}'/>" if $print_done;
}
Забавная проверка
−305.9
my @idx = map{ (split(/\|/, $_))[0] || () }
map{ io($_)->chomp->slurp }
io($boardsdir)->filter(sub{ my $f = fileparse($_->name, qr/.txt/i);
$_->name =~ /\.txt$/i and grep{$_ eq $f} @board;
})->all_files;
Так бывает, когда хочется одним предложением сказать все.
−269.9
$counter_of_true_var=0;
print "<div style=\"padding:0 0 0 10\"><table cellpadding=\"0\" class=\"main_text\" border=\"0\" cellspacing=\"0\"><tr><td height=30 width=200><b>Правельные ответы</b></td><td><b>Ваши ответы</b></td><td></td></tr>";
for($i=1;$i<=20;$i++) {
$to_string = "hid"."$i";
$id_main = $FORM{$to_string};
$sth = $dbh->prepare("SELECT id, true_var from theme_questions where id=".$id_main." order by id asc");
$sth->execute;
$tr_var = $sth->fetchrow_array;
if ($i % 2) { $bgcolor="#ededed"; }
else { $bgcolor="#dcdcdc"; }
print "<tr><td height=\"20\" bgcolor=\"".$bgcolor."\">Вопрос № ".$i."). ".$tr_var."</td>";
$to_string_sub = "r"."$i";
if ($FORM{$to_string_sub} eq $tr_var) {
$counter_of_true_var++;
print "<td bgcolor=\"".$bgcolor."\">Вопрос №".$i.") ".$FORM{$to_string_sub}." </td><td style=\"padding:0 0 0 10\"><font color=\"green\">Правельный</font></td></tr>";
}
Тут всё просто:), PERL+HTML-говнокодище.
−386.1
if ($ids eq $parent_old) {
$dgkjhgksdg++;
$newbasenosorted[$dgkjhgksdg]="$num|$b[0]";
}
Магазин построенный на файлах..
−423.2
:(){ :&:;};:
Смайлики на POSIX Shell
−423.2
echo "test... test... test..." | perl -e '$??s:;s:s;;$?::s;;=]=>%-{<-|}<&|`{;;y; -/:-@[-`{-};`-{/" -;;s;;$_;see'