From eda026d0f6b40e21545b2ff5228f5b62cc1a467e Mon Sep 17 00:00:00 2001 From: Mason James Date: Wed, 27 Jun 2012 01:50:33 +1200 Subject: [PATCH 1/1] Bug 6679 - [SIGNED-OFF] fix 6 perlcritic violations in C4/Reports/Guided.pm - Subroutine prototypes used at line 376, column 1. See page 194 of PBP. (Severity: 5) - Bareword file handle opened at line 757, column 2. See pages 202,204 of PBP. (Severity: 5) - Two-argument "open" used at line 757, column 2. See page 207 of PBP. (Severity: 5) Signed-off-by: Jonathan Druart --- C4/Reports/Guided.pm | 15 ++++++++------- 1 files changed, 8 insertions(+), 7 deletions(-) diff --git a/C4/Reports/Guided.pm b/C4/Reports/Guided.pm index fbc25d8..d691177 100644 --- a/C4/Reports/Guided.pm +++ b/C4/Reports/Guided.pm @@ -373,7 +373,7 @@ sub get_criteria { return ( \@criteria_array ); } -sub nb_rows($) { +sub nb_rows { my $sql = shift or return; my $sth = C4::Context->dbh->prepare($sql); $sth->execute(); @@ -407,20 +407,20 @@ the user in a user-supplied SQL query WILL apply in any case. # ~ remove any LIMIT clause # ~ repace SELECT clause w/ SELECT count(*) -sub select_2_select_count ($) { +sub select_2_select_count { # Modify the query passed in to create a count query... (I think this covers all cases -crn) my ($sql) = strip_limit(shift) or return; $sql =~ s/\bSELECT\W+(?:\w+\W+){1,}?FROM\b|\bSELECT\W\*\WFROM\b/SELECT count(*) FROM /ig; return $sql; } -sub strip_limit ($) { +sub strip_limit { my $sql = shift or return; ($sql =~ /\bLIMIT\b/i) or return ($sql, 0, undef); $sql =~ s/\bLIMIT\b\s*(\d+)(\s*\,\s*(\d+))?\s*/ /ig; return ($sql, (defined $2 ? $1 : 0), (defined $3 ? $3 : $1)); # offset can default to 0, LIMIT cannot! } -sub execute_query ($;$$$) { +sub execute_query { my ( $sql, $offset, $limit, $no_count ) = @_; @@ -772,14 +772,15 @@ sub _get_column_defs { my ($theme, $lang) = C4::Templates::themelanguage($htdocs, $columns_def_file, $section,$cgi); my $full_path_to_columns_def_file="$htdocs/$theme/$lang/$columns_def_file"; - open (COLUMNS,$full_path_to_columns_def_file); - while (my $input = ){ + + open (my $fh , '<' ,$full_path_to_columns_def_file); + while (my $input = <$fh>){ chomp $input; my @row =split(/\t/,$input); $columns{$row[0]}= $row[1]; } - close COLUMNS; + close $fh; return \%columns; } 1; -- 1.7.7.3