Bug 2505: Suppress some warnings emitted by members-home.pl
authorColin Campbell <colin.campbell@ptfs-europe.com>
Mon, 31 Jan 2011 18:09:40 +0000 (18:09 +0000)
committerChris Cormack <chrisc@catalyst.net.nz>
Mon, 11 Jul 2011 09:05:37 +0000 (21:05 +1200)
an undefined value in branch and the undef selected
can generate a large amount of warning noise

Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz>
members/members-home.pl

index 964fdb7..830800e 100755 (executable)
@@ -31,6 +31,8 @@ my $query = new CGI;
 my $branch = $query->param('branchcode');
 my $template_name;
 
+$branch = q{} unless defined $branch;
+
 my ($template, $loggedinuser, $cookie)
     = get_template_and_user({template_name => "members/member.tmpl",
                  query => $query,
@@ -42,13 +44,12 @@ my ($template, $loggedinuser, $cookie)
 
 my $branches = GetBranches;
 my @branchloop;
-foreach (sort { $branches->{$a}->{branchname} cmp $branches->{$b}->{branchname} } keys %$branches) {
-  my $selected = 1 if $branches->{$_}->{branchcode} eq $branch;
-  my %row = ( value => $_,
-        selected => $selected,
+foreach (sort { $branches->{$a}->{branchname} cmp $branches->{$b}->{branchname} } keys %{$branches}) {
+    push @branchloop, {
+        value      => $_,
+        selected   => ($branches->{$_}->{branchcode} eq $branch),
         branchname => $branches->{$_}->{branchname},
-      );
-  push @branchloop, \%row;
+    };
 }
 
 my @categories;