From 74fca575d438232002756175338c23f55b8a6c12 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sven=20Sch=C3=B6ling?= Date: Wed, 26 Oct 2011 17:34:33 +0200 Subject: [PATCH] =?utf8?q?Fixes=20f=C3=BCr=20das=20"my=20$var=20if=20$cond?= =?utf8?q?;"=20pattern.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- SL/CA.pm | 2 +- SL/Common.pm | 4 ++-- SL/DATEV.pm | 2 +- SL/DB/Helper/Sorted.pm | 2 +- SL/DO.pm | 2 +- SL/Form.pm | 8 ++++---- SL/IC.pm | 2 +- SL/IS.pm | 2 +- SL/OE.pm | 2 +- SL/Projects.pm | 2 +- SL/RecordLinks.pm | 2 +- SL/ReportGenerator.pm | 4 ++-- SL/SEPA.pm | 2 +- SL/USTVA.pm | 4 ++-- SL/WH.pm | 2 +- bin/mozilla/am.pl | 3 ++- bin/mozilla/ap.pl | 3 ++- bin/mozilla/gl.pl | 14 +++++++------- bin/mozilla/ic.pl | 2 +- bin/mozilla/io.pl | 4 ++-- bin/mozilla/is.pl | 2 +- bin/mozilla/oe.pl | 5 ++++- bin/mozilla/rp.pl | 3 ++- bin/mozilla/todo.pl | 2 +- bin/mozilla/ustva.pl | 16 ++++++++-------- t/structure/no_lexicals_in_postif.t | 16 +++++++++++++++- 26 files changed, 66 insertions(+), 46 deletions(-) diff --git a/SL/CA.pm b/SL/CA.pm index c200b664e..52d2b0baf 100644 --- a/SL/CA.pm +++ b/SL/CA.pm @@ -84,7 +84,7 @@ sub all_accounts { $amount{ $ref->{accno} } = $ref->{amount}; } - my $where = "AND c.id = $chart_id" if ($chart_id ne ''); + my $where = $chart_id ne '' ? "AND c.id = $chart_id" : ''; $query = qq{ SELECT diff --git a/SL/Common.pm b/SL/Common.pm index c0bca0195..371bb8a7d 100644 --- a/SL/Common.pm +++ b/SL/Common.pm @@ -496,8 +496,8 @@ sub save_email_status { $intnotes .= "\n\n" if ($intnotes); - my $cc = $main::locale->text('Cc') . ": $form->{cc}\n" if $form->{cc}; - my $bcc = $main::locale->text('Bcc') . ": $form->{bcc}\n" if $form->{bcc}; + my $cc = $form->{cc} ? $main::locale->text('Cc') . ": $form->{cc}\n" : ''; + my $bcc = $form->{bcc} ? $main::locale->text('Bcc') . ": $form->{bcc}\n" : ''; my $now = scalar localtime; $intnotes .= $main::locale->text('[email]') . "\n" diff --git a/SL/DATEV.pm b/SL/DATEV.pm index 6c6f1c744..7f38c88c1 100644 --- a/SL/DATEV.pm +++ b/SL/DATEV.pm @@ -942,7 +942,7 @@ sub kne_stammdatenexport { push @values, $form->{accnoto}; } - my $where_str = ' WHERE ' . join(' AND ', map { "($_)" } @where) if (scalar @where); + my $where_str = @where ? ' WHERE ' . join(' AND ', map { "($_)" } @where) : ''; my $query = qq|SELECT c.accno, c.description FROM chart c diff --git a/SL/DB/Helper/Sorted.pm b/SL/DB/Helper/Sorted.pm index 9442c842e..1b6c42a3c 100644 --- a/SL/DB/Helper/Sorted.pm +++ b/SL/DB/Helper/Sorted.pm @@ -47,7 +47,7 @@ sub _get_sort_spec { sub _make_sort_spec { my ($class) = @_; - my %sort_spec = $class->_sort_spec if defined &{ "${class}::_sort_spec" }; + my %sort_spec = defined &{ "${class}::_sort_spec" } ? $class->_sort_spec : (); my $meta = $class->object_class->meta; diff --git a/SL/DO.pm b/SL/DO.pm index 5b5cf1d13..0d2a5ec21 100644 --- a/SL/DO.pm +++ b/SL/DO.pm @@ -408,7 +408,7 @@ sub mark_orders_if_delivered { 'to_table' => 'delivery_orders', 'to_id' => $params{do_id}); - my ($oe_id) = $links[0]->{from_id} if (scalar @links); + my $oe_id = @links ? $links[0]->{from_id} : undef; return $main::lxdebug->leave_sub() if (!$oe_id); diff --git a/SL/Form.pm b/SL/Form.pm index da832f871..15d66cec9 100644 --- a/SL/Form.pm +++ b/SL/Form.pm @@ -2341,7 +2341,7 @@ sub _get_taxcharts { $key = $params; } - my $where = ' WHERE ' . join(' AND ', map { "($_)" } @where) if (@where); + my $where = @where ? ' WHERE ' . join(' AND ', map { "($_)" } @where) : ''; my $query = qq|SELECT * FROM tax $where ORDER BY taxkey|; @@ -2456,7 +2456,7 @@ sub _get_customers { my $options = ref $key eq 'HASH' ? $key : { key => $key }; $options->{key} ||= "all_customers"; - my $limit_clause = "LIMIT $options->{limit}" if $options->{limit}; + my $limit_clause = $options->{limit} ? "LIMIT $options->{limit}" : ''; my @where; push @where, qq|business_id IN (SELECT id FROM business WHERE salesman)| if $options->{business_is_salesman}; @@ -3665,8 +3665,8 @@ sub prepare_for_printing { $extension = 'xls'; } - my $printer_code = '_' . $self->{printer_code} if $self->{printer_code}; - my $email_extension = '_email' if -f "$self->{templates}/$self->{formname}_email${language}${printer_code}.${extension}"; + my $printer_code = $self->{printer_code} ? '_' . $self->{printer_code} : ''; + my $email_extension = -f "$::myconfig{templates}/$self->{formname}_email${language}.${extension}" ? '_email' : ''; $self->{IN} = "$self->{formname}${email_extension}${language}${printer_code}.${extension}"; # Format dates. diff --git a/SL/IC.pm b/SL/IC.pm index 82b43cd4c..8fd928167 100644 --- a/SL/IC.pm +++ b/SL/IC.pm @@ -1048,7 +1048,7 @@ sub all_parts { my $select_clause = join ', ', map { $token_builder->($_, 1) } @select_tokens; my $join_clause = join ' ', @joins{ grep $joins_needed{$_}, @join_order }; my $where_clause = join ' AND ', map { "($_)" } @where_tokens; - my $group_clause = ' GROUP BY ' . join ', ', map { $token_builder->($_) } @group_tokens if scalar @group_tokens; + my $group_clause = @group_tokens ? ' GROUP BY ' . join ', ', map { $token_builder->($_) } @group_tokens : ''; my %oe_flag_to_cvar = ( bought => 'invoice', diff --git a/SL/IS.pm b/SL/IS.pm index c9a44281d..3aa0d3ca9 100644 --- a/SL/IS.pm +++ b/SL/IS.pm @@ -1440,7 +1440,7 @@ sub retrieve_invoice { my ($sth, $ref, $query); - my $query_transdate = ", current_date AS invdate" if !$form->{id}; + my $query_transdate = !$form->{id} ? ", current_date AS invdate" : ''; $query = qq|SELECT diff --git a/SL/OE.pm b/SL/OE.pm index bfa43f235..969402692 100644 --- a/SL/OE.pm +++ b/SL/OE.pm @@ -190,7 +190,7 @@ SQL } if ($form->{periodic_invoices_active} ne $form->{periodic_invoices_inactive}) { - my $not = 'NOT' if ($form->{periodic_invoices_inactive}); + my $not = $form->{periodic_invoices_inactive} ? 'NOT' : ''; $query .= qq| AND ${not} COALESCE(pcfg.active, 'f')|; } diff --git a/SL/Projects.pm b/SL/Projects.pm index c25e75ae3..d3df51fdd 100644 --- a/SL/Projects.pm +++ b/SL/Projects.pm @@ -104,7 +104,7 @@ sub search_projects { } - my $where = 'WHERE ' . join(' AND ', map { "($_)" } @filters) if (scalar @filters); + my $where = @filters ? 'WHERE ' . join(' AND ', map { "($_)" } @filters) : ''; my $sortorder = $params{sort} ? $params{sort} : "projectnumber"; $sortorder =~ s/[^a-z_]//g; diff --git a/SL/RecordLinks.pm b/SL/RecordLinks.pm index cef2c4df0..da63872d4 100644 --- a/SL/RecordLinks.pm +++ b/SL/RecordLinks.pm @@ -193,7 +193,7 @@ sub delete { add_token(\@where_tokens, \@where_values, col => $col, val => $params{$col}) if $params{$col}; } - my $where = "WHERE ". join ' AND ', map { "($_)" } @where_tokens if scalar @where_tokens; + my $where = @where_tokens ? "WHERE ". join ' AND ', map { "($_)" } @where_tokens : ''; my $query = "DELETE FROM record_links $where"; do_query($form, $dbh, $query, @where_values); diff --git a/SL/ReportGenerator.pm b/SL/ReportGenerator.pm index 441eb159d..6b9990180 100644 --- a/SL/ReportGenerator.pm +++ b/SL/ReportGenerator.pm @@ -564,8 +564,8 @@ sub generate_pdf_content { my $font_height = $font_size + 2 * $padding; my $title_font_height = $font_size + 2 * $padding; - my $header_height = 2 * $title_font_height if ($opts->{title}); - my $footer_height = 2 * $font_height if ($pdfopts->{number}); + my $header_height = $opts->{title} ? 2 * $title_font_height : undef; + my $footer_height = $pdfopts->{number} ? 2 * $font_height : undef; my $top_text_height = 0; diff --git a/SL/SEPA.pm b/SL/SEPA.pm index 32e763cdb..ced75be7e 100644 --- a/SL/SEPA.pm +++ b/SL/SEPA.pm @@ -305,7 +305,7 @@ sub list_exports { push @where, 'se.vc = ?'; push @values, $vc; - my $where = ' WHERE ' . join(' AND ', map { "(${_})" } @where) if (@where); + my $where = @where ? ' WHERE ' . join(' AND ', map { "(${_})" } @where) : ''; my $query = qq|SELECT se.id, se.employee_id, se.executed, se.closed, itime::date AS export_date, diff --git a/SL/USTVA.pm b/SL/USTVA.pm index 1cec7447c..abbf4a32c 100644 --- a/SL/USTVA.pm +++ b/SL/USTVA.pm @@ -113,8 +113,8 @@ sub report_variables { my $attribute = $arg_ref->{attribute}; # my $dec_places = (defined $arg_ref->{dec_places}) ? $arg_ref->{dec_places}:undef; - my $where_type = "AND tax.report_headings.type = '$type'" if ( $type ); - my $where_dcp = "AND tax.report_variables.dec_places = '$dec_places'" if ( defined $dec_places ); + my $where_type = $type ? "AND tax.report_headings.type = '$type'" : ''; + my $where_dcp = defined $dec_places ? "AND tax.report_variables.dec_places = '$dec_places'" : ''; my $query = qq| SELECT $attribute diff --git a/SL/WH.pm b/SL/WH.pm index 04b1914e0..2a5039d29 100644 --- a/SL/WH.pm +++ b/SL/WH.pm @@ -351,7 +351,7 @@ sub get_warehouse_journal { $sort_order = $filter{order} unless $sort_order; my $sort_spec = "${sort_col} " . ($sort_order ? " DESC" : " ASC"); - my $where_clause = join(" AND ", @filter_ary) . " AND " if (@filter_ary); + my $where_clause = @filter_ary ? join(" AND ", @filter_ary) . " AND " : ''; $select_tokens{'trans'} = { "parts_id" => "i1.parts_id", diff --git a/bin/mozilla/am.pl b/bin/mozilla/am.pl index 111e14e94..b6996d169 100644 --- a/bin/mozilla/am.pl +++ b/bin/mozilla/am.pl @@ -2051,7 +2051,8 @@ sub show_am_history { my $dbh = $form->dbconnect(\%myconfig); - my $restriction = qq| AND (| . join(' OR ', map { " addition = " . $dbh->quote($_) } split(m/\,/, $form->{einschraenkungen})) . qq|)| if $form->{einschraenkungen}; + my $restriction; + $restriction = qq| AND (| . join(' OR ', map { " addition = " . $dbh->quote($_) } split(m/\,/, $form->{einschraenkungen})) . qq|)| if $form->{einschraenkungen}; $restriction .= qq| AND h.itime::date >= | . conv_dateq($form->{fromdate}) if $form->{fromdate}; $restriction .= qq| AND h.itime::date <= | . conv_dateq($form->{todate}) if $form->{todate}; if ($form->{mitarbeiter} =~ m/^\d+$/) { diff --git a/bin/mozilla/ap.pl b/bin/mozilla/ap.pl index 6d24657f3..f62294eaa 100644 --- a/bin/mozilla/ap.pl +++ b/bin/mozilla/ap.pl @@ -285,7 +285,8 @@ sub form_header { my $notes = qq||; - my $department = qq| + my $department; + $department = qq| | . $locale->text('Department') . qq| diff --git a/bin/mozilla/gl.pl b/bin/mozilla/gl.pl index 6ef1ca3e3..625490dc8 100644 --- a/bin/mozilla/gl.pl +++ b/bin/mozilla/gl.pl @@ -234,7 +234,8 @@ sub search { } (@{ $form->{all_departments} || [] }); } - my $department = qq| + my $department; + $department = qq| | . $locale->text('Department') . qq| @@ -1017,7 +1018,7 @@ sub display_rows { my $projectnumber_hidden = qq| |; - my $copy2credit = 'onkeyup="copy_debit_to_credit()"' if $i == 1; + my $copy2credit = $i == 1 ? 'onkeyup="copy_debit_to_credit()"' : ''; print qq| $accno @@ -1079,10 +1080,9 @@ sub form_header { $form->{title} = $locale->text("$title General Ledger Transaction"); my $readonly = ($form->{id}) ? "readonly" : ""; - my $show_details_checked = "checked" if $form->{show_details}; - - my $ob_transaction_checked = "checked" if $form->{ob_transaction}; - my $cb_transaction_checked = "checked" if $form->{cb_transaction}; + my $show_details_checked = $form->{show_details} ? "checked" : ''; + my $ob_transaction_checked = $form->{ob_transaction} ? "checked" : ''; + my $cb_transaction_checked = $form->{cb_transaction} ? "checked" : ''; # $locale->text('Add General Ledger Transaction') # $locale->text('Edit General Ledger Transaction') @@ -1410,7 +1410,7 @@ $follow_ups_block } else { if ($form->{draft_id}) { - my $remove_draft_checked = 'checked' if ($form->{remove_draft}); + my $remove_draft_checked = $form->{remove_draft} ? 'checked' : ''; print qq|

\n| . qq| | . qq| \n| diff --git a/bin/mozilla/ic.pl b/bin/mozilla/ic.pl index 215ec16ab..a30378123 100644 --- a/bin/mozilla/ic.pl +++ b/bin/mozilla/ic.pl @@ -1273,7 +1273,7 @@ sub generate_report { my %subtotals = map { $_ => 0 } ('onhand', @subtotal_columns); my %totals = map { $_ => 0 } @subtotal_columns; my $idx = 0; - my $same_item = $form->{parts}[0]{ $form->{sort} } if (scalar @{ $form->{parts} }); + my $same_item = @{ $form->{parts} } ? $form->{parts}[0]{ $form->{sort} } : undef; my $defaults = AM->get_defaults(); diff --git a/bin/mozilla/io.pl b/bin/mozilla/io.pl index a4e027d6c..2d23c76ae 100644 --- a/bin/mozilla/io.pl +++ b/bin/mozilla/io.pl @@ -359,7 +359,7 @@ sub display_row { # calculate onhand if ($form->{"id_$i"}) { my $part = IC->get_basic_part_info(id => $form->{"id_$i"}); - my $onhand_color = 'color="#ff0000"' if $part->{onhand} < $part->{rop}; + my $onhand_color = $part->{onhand} < $part->{rop} ? 'color="#ff0000"' : ''; push @ROW2, { value => sprintf "%s %s %s", $locale->text('On Hand'), $onhand_color, @@ -1457,7 +1457,7 @@ sub print_form { $extension = 'xls'; } - my $email_extension = '_email' if (($form->{media} eq 'email') && (-f "$myconfig{templates}/$form->{formname}_email$form->{language}${printer_code}.${extension}")); + my $email_extension = (($form->{media} eq 'email') && (-f "$myconfig{templates}/$form->{formname}_email$form->{language}${printer_code}.${extension}")) ? '_email' : ''; $form->{IN} = "$form->{formname}${email_extension}$form->{language}${printer_code}.${extension}"; diff --git a/bin/mozilla/is.pl b/bin/mozilla/is.pl index 19f546db3..686de618b 100644 --- a/bin/mozilla/is.pl +++ b/bin/mozilla/is.pl @@ -489,7 +489,7 @@ sub update { $form->{exchangerate} = $form->parse_amount(\%myconfig, $form->{exchangerate}) unless $recursive_call; $form->{print_and_post} = 0 if $form->{second_run}; - my $taxincluded = "checked" if $form->{taxincluded}; + my $taxincluded = $form->{taxincluded} ? "checked" : ''; $form->{update} = 1; &check_name("customer"); diff --git a/bin/mozilla/oe.pl b/bin/mozilla/oe.pl index 24540eed8..c9ddfa5be 100644 --- a/bin/mozilla/oe.pl +++ b/bin/mozilla/oe.pl @@ -1301,7 +1301,10 @@ sub invoice { $form->{quodate} = $form->{transdate}; } - my $payment_id = $form->{payment_id} if $form->{payment_id}; + my $payment_id; + if ($form->{payment_id}) { + $payment_id = $form->{payment_id}; + } # if the name changed get new values if (&check_name($form->{vc})) { diff --git a/bin/mozilla/rp.pl b/bin/mozilla/rp.pl index 062c44f4e..dc1b15384 100644 --- a/bin/mozilla/rp.pl +++ b/bin/mozilla/rp.pl @@ -158,7 +158,8 @@ sub report { map { $form->{selectdepartment} .= "