- 1
- 2
- 3
- 4
- 5
- 6
foreach my $current_item(@catalog_items)
{
foreach($current_item)
{
my $id = $_->[0];
...
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
−103
foreach my $current_item(@catalog_items)
{
foreach($current_item)
{
my $id = $_->[0];
...
−55.2
return ('3');
Возвращаем код ошибки.
−118.3
if ( $in{s} )
{
# максимальная вложенность =3 - сформируем строку для чекбокса по-простому
my %ha = db_select_row [ 'id', 'title', 'parent_id' ], "catalog_section", "id=$in{s} AND `object_id`=1";
if (%ha) ¦
{ ¦
$selected_only[ $ha{parent_id} ] = 'selected';
} ¦
¦
my %parent = db_select_row [ 'title', 'parent_id' ], "catalog_section", "id=$ha{parent_id} AND `object_id`=1";
my %parent2 = db_select_row [ 'title', 'parent_id' ], "catalog_section", "id=$parent{parent_id} AND `object_id`=1";
my $only_title = $ha{title};
$only_title = "$parent{title} — $only_title" if %parent;
$only_title = "$parent2{title} — $only_title" if %parent2;
$only_this_cat_string = "";
if ( %parent || %parent2 )
{
#%ha
$only_this_category_text = qq~
<span>
<input type="checkbox" name="only_this_cat" id="only_this_cat" $checked_only onchange="checkSelect();">
<label for="only_this_cat">Искать только в разделе «$only_title»</label>
</span>~;
}
}
по-простому
−55.1
#Пример раз
my %parse_hash = (
$sub_dir => $dir,
$sub_style_dir => $style_dir,
$sub_image_dir => $image_dir
);
#Пример два
...
elsif ($event eq $Event_View_Par){
print &ViewPar(%Query);
}
elsif ($event eq $Event_View_All){
print &ViewPar(%Query);
}
elsif ($event eq $Event_View_Asset){
print &ViewAsset(%Query);
}
Пример 1: В качестве ключей хэша переменные, которые определены в другом файле.
Пример 2: переменные $Event_View* определены в другом, используются только здесь и больше нигде
И так по всему коду
Задалбывает всё время переключаться alt-табом на файл, смотреть на определение переменных
−109.3
$in{item_name}=CGI::unescape($in{item_name});
$in{item_number}=CGI::unescape($in{item_number});
#убиваем пробелы сначала, с конца и двойные
###
if($in{item_name}=~/^[\s]+([\s\S]+)/) {
$in{item_name}=$1;
}
if($in{item_name}=~/([\s\S]+)[\s]+$/) {
$in{item_name}=$1;
}
$in{item_name}=~s/[\s]{2,}/ /g;
if($in{item_number}=~/^[\s]+([\s\S]+)/) {
$in{item_number}=$1;
}
if($in{item_number}=~/([\s\S]+)[\s]+$/) {
$in{item_number}=$1;
}
$in{item_number}=~s/[\s]{2,}/ /g;
####
my @select_parent=db_select_list ['title','id'],"catalog_section","parent_id=0";
###########
my $only_this_category_text;
my $checked_only;
if($in{action} eq 'filter' and !$in{only_this_cat}) { $checked_only=''; } else {$checked_only="checked"; }
#############################
my $selected_list_item;
my $only_this_cat_string;
my @selected_only;
my $selected_parent;
#die $in{only_this_cat_s};
for(@select_parent)
{my $name="index_sel_$$_{id}";
if($in{action} eq 'filter' and ($in{only_this_cat_s} eq $$_{id})) {$selected_only[$$_{id}]='selected'; } else { $selected_only[$$_{id}]=''; }
if(!$in{only_this_cat_s})
{ if(!$in{action} and ($in{s} eq $$_{id})) {$selected_only[$$_{id}]='selected'; } else { $selected_only[$$_{id}]=''; }
}else{ if($in{only_this_cat_s} eq $$_{id}){ $selected_only[$$_{id}]='selected';}}
}
############################
if($in{s}) {
#максимальная вложенность =3 - сформируем строку для чекбокса по-простому
my %ha=db_select_row ['id','title','parent_id'],"catalog_section","id=$in{s}";
if(%ha){$selected_only[$ha{parent_id}]='selected';}
my %parent=db_select_row ['title','parent_id'],"catalog_section","id=$ha{parent_id}";
my %parent2=db_select_row ['title','parent_id'],"catalog_section","id=$parent{parent_id}";
my $only_title=$ha{title};
$only_title= "$parent{title} — $only_title" if %parent;
$only_title= "$parent2{title} — $only_title" if %parent2;
$only_this_cat_string="";
if(%parent || %parent2) {#%ha
$only_this_category_text=qq~
<span>
<input type="checkbox" name="only_this_cat" id="only_this_cat" $checked_only onchange="checkSelect();">
<label for="only_this_cat">Искать только в разделе «$only_title»</label>
</span>~;
}
}
$selected_list_item=qq~<select name="only_this_cat_s" id="only_this_cat_s"> <OPTION VALUE='none'>Все разделы</OPTION>~;
for(@select_parent)
{
$selected_list_item.=qq~<OPTION VALUE='$$_{id}' $selected_only[$$_{id}]~;
$selected_list_item.=qq~><label for="only_this_cat_s">$$_{title}</label>
</OPTION>~;
}
$selected_list_item.=qq~</select></td>~;
$only_this_cat_string="Раздел каталога";
Оригинальное форматирование сохранено
−117.2
my $cache_sql="SELECT `content`, `insertTime` FROM _cache WHERE `confid`='$$conf{confid}'";
...
$cache_sql.=" AND `location`=".$self->{dbh}->quote($url);
...
$cache_sql.=" AND `cgiparams`=".$self->{dbh}->quote($cgi_hash);
...
$cache_sql.=" AND `callparams`=".$self->{dbh}->quote($callp_hash);
...
$cache_sql.=" AND `userid`=".int($$params{userid});
...
$cache_sql.=" AND `groupid`=".int($$params{groupid});
my $replace_sql=$cache_sql;
$replace_sql=~s/SELECT.*?FROM\s+_cache\s+WHERE/REPLACE INTO _cache SET/s;
perl+sql
−101
my $iref=$self->{ditems}->_get_item({itemid=>$weather_itemid, set=>'Weather', fields=>['MinT', 'MaxT', 'Precip', 'Cloud', 'twater'], prefix=>$$p{prefix}});
if ($$iref{$$p{prefix}.'MinT'}<0 && $$iref{$$p{prefix}.'MaxT'}<=0) {
my $tmp=$$iref{$$p{prefix}.'MaxT'};
$$iref{$$p{prefix}.'MaxT'}=$$iref{$$p{prefix}.'MinT'};
$$iref{$$p{prefix}.'MaxT'}=$tmp;
};
#warn $$iref{$$p{prefix}.'MinT'} if !$$iref{$$p{prefix}.'MinT'}>0;
$$iref{$$p{prefix}.'T'}=int( ($$iref{$$p{prefix}.'MinT'}+$$iref{$$p{prefix}.'MaxT'})/2 );
$$iref{$$p{prefix}.'T'}='+'.$$iref{$$p{prefix}.'T'} if $$iref{$$p{prefix}.'T'}>0;
#$$iref{$$p{prefix}.'T'}=~s/\-/\&\#150\;/gs;
$$iref{$$p{prefix}.'MinT'}='+'.$$iref{$$p{prefix}.'MinT'} if ($$iref{$$p{prefix}.'MinT'}>0);
$$iref{$$p{prefix}.'MaxT'}='+'.$$iref{$$p{prefix}.'MaxT'} if ($$iref{$$p{prefix}.'MaxT'}>0);
$$iref{$$p{prefix}.'twater'}='+'.$$iref{$$p{prefix}.'twater'} if ($$iref{$$p{prefix}.'twater'}>0);
$$iref{$$p{prefix}.'time'}=$$p{daystart}+$$p{hour}*3600;
−55.2
#!/etc/Tivoli/bin/perl
##############################################################
# Name: Default.cgi
#
# Description: Generates translated Default HTML page
# according to browser's language
# TMF 4.1
# Licensed Materials- Property of IBM
# (C) Copyright IBM Corp. 2000. All Rights Reserved
#
# US Government Users Restricted Rights- Use, duplication,
# or disclosure restricted by GSA ADP Schedule Contract with
# IBM Corp.
##############################################################
# wupddefhtml will bind all messages contained in default page
# accordingly ( LANG is set to the browser's locale )
$defaultPage=`wupddefhtml -out`;
# all links in the default page are absolute or relative to root
# so we need to fix them because we have changed location
$defaultPage =~ s|href=|href=../|g;
$defaultPage =~ s|//|/|g;
print("HTTP/1.0 200 OK
Contents-Type: text/html
");
print "$defaultPage";
строка print("HTTP/1.0 200 OK
явно говорит о глубоких знаниях протокола :))
(C) Copyright IBM Corp. - ИТ лидер - что еще сказать
−150
print $string =~ /([http|ftp|https]+:\/\/[\w\/\.\?\&\=]+)/;
Типичный индусский регэксп (в данном случае ищет УРЛ в строчке)
−147
if (!@ARGV){
die ("Usage: palindrom.pl word\n");
}
$text = $ARGV[0];
if (length($text) < 4){
die ("Error: Word must be not less than 4 leters\n");
}
if ($text =~ m/(.)(.). ?\2\1/){
print "Result: Match\n";
}
else{
print "Result: Not match\n";
}
Код как-бэ проверяет является ли слово палиндромом.
На самом деле проверяются только первые два символа с начала и конца. То есть строка "alla123h5vj3galla" является палиндромом.