[LON-CAPA-cvs] cvs: loncom /interface lonfeedback.pm

raeburn lon-capa-cvs@mail.lon-capa.org
Wed, 29 Nov 2006 03:55:16 -0000


This is a MIME encoded message

--raeburn1164772516
Content-Type: text/plain

raeburn		Tue Nov 28 22:55:16 2006 EDT

  Modified files:              
    /loncom/interface	lonfeedback.pm 
  Log:
  Eliminate $_
  
  Style - push() keys() sort() split()
  
  
--raeburn1164772516
Content-Type: text/plain
Content-Disposition: attachment; filename="raeburn-20061128225516.txt"

Index: loncom/interface/lonfeedback.pm
diff -u loncom/interface/lonfeedback.pm:1.220 loncom/interface/lonfeedback.pm:1.221
--- loncom/interface/lonfeedback.pm:1.220	Tue Nov 28 22:23:02 2006
+++ loncom/interface/lonfeedback.pm	Tue Nov 28 22:55:15 2006
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Feedback
 #
-# $Id: lonfeedback.pm,v 1.220 2006/11/29 03:23:02 raeburn Exp $
+# $Id: lonfeedback.pm,v 1.221 2006/11/29 03:55:15 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -133,7 +133,7 @@
     my $previous = 0;
     my $visit = 0;
     my $newpostsflag = 0;
-    my @posters = split/\&/,$dischash{$userpickkey};
+    my @posters = split(/\&/,$dischash{$userpickkey});
 
 # Retain identification of "NEW" posts identified in last display, if continuing 'previous' browsing of posts.
     &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['previous','sortposts','rolefilter','statusfilter','sectionpick','grouppick','totposters']);
@@ -162,19 +162,19 @@
     my ($classgroups,$studentgroups);
     if ($env{'form.rolefilter'}) {
         %roleshash = &Apache::lonnet::dump('nohist_userroles',$cdom,$cnum);
-        foreach (keys %roleshash) {
-            my ($role,$uname,$udom,$sec) = split/:/,$_;
+        foreach my $rolekey (keys(%roleshash)) {
+            my ($role,$uname,$udom,$sec) = split(/:/,$rolekey);
             if ($role =~ /^cr/) {
                 $role = 'cr';
             }
-            my ($end,$start) = split/:/,$roleshash{$_};
+            my ($end,$start) = split(/:/,$roleshash{$rolekey});
             my $now = time;
             my $status = 'Active';
             if (($now < $start) || ($end > 0 && $now > $end)) {
                 $status = 'Expired';
             }
             if ($uname && $udom) { 
-                push @{$roleinfo{$uname.':'.$udom}}, $role.':'.$sec.':'.$status;
+                push(@{$roleinfo{$uname.':'.$udom}}, $role.':'.$sec.':'.$status);
             }
         }
         my ($classlist,$keylist) =
@@ -184,7 +184,7 @@
         while (my ($student,$data) = each %$classlist) {
             my ($section,$status) = ($data->[$sec_index],
                                  $data->[$status_index]);
-            push @{$roleinfo{$student}}, 'st:'.$section.':'.$status;
+            push(@{$roleinfo{$student}}, 'st:'.$section.':'.$status);
         }
 	($classgroups,$studentgroups) = 
 	    &Apache::loncoursedata::get_group_memberships($classlist,$keylist,
@@ -493,39 +493,39 @@
 # Choose sort mechanism
         my @showposts = ();
         if ($sortposts eq 'descdate') {
-            @showposts = (sort { $b <=> $a } keys %alldiscussion);
+            @showposts = (sort { $b <=> $a } keys(%alldiscussion));
         } elsif ($sortposts eq 'thread') {
-            @showposts = (sort { $a <=> $b } keys %alldiscussion);
+            @showposts = (sort { $a <=> $b } keys(%alldiscussion));
         } elsif ($sortposts eq 'subject') {
-            foreach (sort keys %subjectsort) {
-                push @showposts, @{$subjectsort{$_}};
+            foreach my $key (sort(keys(%subjectsort))) {
+                push(@showposts, @{$subjectsort{$key}});
             }
         } elsif ($sortposts eq 'username') {
-            foreach my $domain (sort keys %usernamesort) {
-                foreach (sort keys %{$usernamesort{$domain}}) {
-                    push @showposts, @{$usernamesort{$domain}{$_}};
+            foreach my $domain (sort(keys(%usernamesort))) {
+                foreach my $key (sort(keys(%{$usernamesort{$domain}}))) {
+                    push(@showposts, @{$usernamesort{$domain}{$key}});
                 }
             }
         } elsif ($sortposts eq 'lastfirst') {
-            foreach my $last (sort keys %namesort) {
-                 foreach (sort keys %{$namesort{$last}}) {
-                     push @showposts, @{$namesort{$last}{$_}};
+            foreach my $last (sort(keys(%namesort))) {
+                 foreach my $key (sort(keys(%{$namesort{$last}}))) {
+                     push(@showposts, @{$namesort{$last}{$key}});
                  }
             }
         } else {
-            @showposts =  (sort { $a <=> $b } keys %alldiscussion);
+            @showposts =  (sort { $a <=> $b } keys(%alldiscussion));
         }
         my $currdepth = 0;
         my $firstidx = $alldiscussion{$showposts[0]};
-        foreach (@showposts) {
+        foreach my $post (@showposts) {
             unless (($sortposts eq 'thread') || (($sortposts eq '') && ($env{'environment.threadeddiscussion'})) || ($outputtarget eq 'export')) {
-                $alldiscussion{$_} = $_;
+                $alldiscussion{$post} = $post;
             }
-            unless ( ($notshown{$alldiscussion{$_}} eq '1') || ($shown{$alldiscussion{$_}} == 0) ) {
+            unless ( ($notshown{$alldiscussion{$post}} eq '1') || ($shown{$alldiscussion{$post}} == 0) ) {
                 if ($outputtarget ne 'tex' && $outputtarget ne 'export') {
 		    $discussion.="\n<tr>";
 		}
-	        my $thisdepth=$depth[$alldiscussion{$_}];
+	        my $thisdepth=$depth[$alldiscussion{$post}];
                 if ($outputtarget ne 'tex' && $outputtarget ne 'export') {
 		    for (1..$thisdepth) {
 			$discussion.='<td>&nbsp;&nbsp;&nbsp;</td>';
@@ -534,52 +534,52 @@
 	        my $colspan=$maxdepth-$thisdepth+1;
                 if ($outputtarget eq 'tex') {
 		    #cleanup block
-		    $discussionitems[$alldiscussion{$_}]=~s/<table([^>]*)>/<table TeXwidth="90 mm">/;
-		    $discussionitems[$alldiscussion{$_}]=~s/<tr([^>]*)><td([^>]*)>/<tr><td TeXwidth="20 mm" align="left">/;
+		    $discussionitems[$alldiscussion{$post}]=~s/<table([^>]*)>/<table TeXwidth="90 mm">/;
+		    $discussionitems[$alldiscussion{$post}]=~s/<tr([^>]*)><td([^>]*)>/<tr><td TeXwidth="20 mm" align="left">/;
                     my $threadinsert='';
                     if ($thisdepth > 0) {
 			$threadinsert='<br /><strong>Reply: '.$thisdepth.'</strong>';
 		    }
-		    $discussionitems[$alldiscussion{$_}]=~s/<\/td><td([^>]*)>/$threadinsert<\/td><td TeXwidth="65 mm" align="left">/;
-		    $discussionitems[$alldiscussion{$_}]=~s/<a([^>]+)>(Edit|Hide|Delete|Reply|Submissions)<\/a>//g;
-                    $discussionitems[$alldiscussion{$_}]=~s/(<b>|<\/b>|<\/a>|<a([^>]+)>)//g;
+		    $discussionitems[$alldiscussion{$post}]=~s/<\/td><td([^>]*)>/$threadinsert<\/td><td TeXwidth="65 mm" align="left">/;
+		    $discussionitems[$alldiscussion{$post}]=~s/<a([^>]+)>(Edit|Hide|Delete|Reply|Submissions)<\/a>//g;
+                    $discussionitems[$alldiscussion{$post}]=~s/(<b>|<\/b>|<\/a>|<a([^>]+)>)//g;
 
-		    $discussionitems[$alldiscussion{$_}]='<tex>\vskip 0 mm\noindent\makebox[2 cm][b]{\hrulefill}</tex>'.$discussionitems[$alldiscussion{$_}];
-		    $discussion.=$discussionitems[$alldiscussion{$_}];
+		    $discussionitems[$alldiscussion{$post}]='<tex>\vskip 0 mm\noindent\makebox[2 cm][b]{\hrulefill}</tex>'.$discussionitems[$alldiscussion{$post}];
+		    $discussion.=$discussionitems[$alldiscussion{$post}];
 		} elsif ($outputtarget eq 'export') {
-                    my $postfilename = $alldiscussion{$_}.'-'.$imsitems{$alldiscussion{$_}}{'timestamp'}.'.html';
+                    my $postfilename = $alldiscussion{$post}.'-'.$imsitems{$alldiscussion{$post}}{'timestamp'}.'.html';
                     if ($manifestok) {
-                        if (($depth[$alldiscussion{$_}] <= $currdepth) && ($alldiscussion{$_} != $firstidx)) {
+                        if (($depth[$alldiscussion{$post}] <= $currdepth) && ($alldiscussion{$post} != $firstidx)) {
                             print $manifestfile '  </item>'."\n";
                         }
-                        $currdepth = $depth[$alldiscussion{$_}];
+                        $currdepth = $depth[$alldiscussion{$post}];
                         print $manifestfile "\n". 
-      '<item identifier="ITEM-'.$ressymb.'-'.$alldiscussion{$_}.'" isvisible="'.
-        $imsitems{$alldiscussion{$_}}{'isvisible'}.'" identifieref="RES-'.$ressymb.'-'.$alldiscussion{$_}.'">'.
-        '<title>'.$imsitems{$alldiscussion{$_}}{'title'}.'</title>';
+      '<item identifier="ITEM-'.$ressymb.'-'.$alldiscussion{$post}.'" isvisible="'.
+        $imsitems{$alldiscussion{$post}}{'isvisible'}.'" identifieref="RES-'.$ressymb.'-'.$alldiscussion{$post}.'">'.
+        '<title>'.$imsitems{$alldiscussion{$post}}{'title'}.'</title>';
                         $imsresources .= "\n".
-    '<resource identifier="RES-'.$ressymb.'-'.$alldiscussion{$_}.'" type="webcontent" href="'.$postfilename.'">'."\n".
+    '<resource identifier="RES-'.$ressymb.'-'.$alldiscussion{$post}.'" type="webcontent" href="'.$postfilename.'">'."\n".
       '<file href="'.$postfilename.'">'."\n".
-      $imsfiles{$alldiscussion{$_}}{$imsitems{$alldiscussion{$_}}{'currversion'}}."\n".
+      $imsfiles{$alldiscussion{$post}}{$imsitems{$alldiscussion{$post}}{'currversion'}}."\n".
     '</resource>';
                     }
                     my $postingfile;
                     my $postingfilename = $tempexport.'/'.$postfilename;
                     if ($postingfile = Apache::File->new('>'.$postingfilename)) {
                         print $postingfile '<html><head><title>Discussion Post</title></head><body>'.
-                                           $imsitems{$alldiscussion{$_}}{'title'}.' '.
-                                           $imsitems{$alldiscussion{$_}}{'sender'}.
-                                           $imsitems{$alldiscussion{$_}}{'timestamp'}.'<br /><br />'.
-                                           $imsitems{$alldiscussion{$_}}{'message'}.'<br />'.
-                                           $imsitems{$alldiscussion{$_}}{'attach'}.'</body></html>'."\n"; 
+                                           $imsitems{$alldiscussion{$post}}{'title'}.' '.
+                                           $imsitems{$alldiscussion{$post}}{'sender'}.
+                                           $imsitems{$alldiscussion{$post}}{'timestamp'}.'<br /><br />'.
+                                           $imsitems{$alldiscussion{$post}}{'message'}.'<br />'.
+                                           $imsitems{$alldiscussion{$post}}{'attach'}.'</body></html>'."\n"; 
                         close($postingfile);
                     } else {
-                        $discussion .= $lt{'aerr'}.' '.$alldiscussion{$_}.'<br />';
+                        $discussion .= $lt{'aerr'}.' '.$alldiscussion{$post}.'<br />';
                     }
-                    $copyresult.=&replicate_attachments($imsitems{$alldiscussion{$_}}{'allattachments'},$tempexport);
+                    $copyresult.=&replicate_attachments($imsitems{$alldiscussion{$post}}{'allattachments'},$tempexport);
                 } else {
-                    $discussion.='<td  bgcolor="'.$bgcols[$newitem{$alldiscussion{$_}}].
-                       '" colspan="'.$colspan.'">'. $discussionitems[$alldiscussion{$_}].
+                    $discussion.='<td  bgcolor="'.$bgcols[$newitem{$alldiscussion{$post}}].
+                       '" colspan="'.$colspan.'">'. $discussionitems[$alldiscussion{$post}].
                        '</td></tr>';
                 }
 	    }
@@ -652,8 +652,8 @@
                     }
                     if (@rolefilter > 0) {
                         $filterchoice .= '<i>'.&mt('roles').'</i>-';
-                        foreach (@rolefilter) {
-                            $filterchoice .= '&nbsp;'.$role_types{$_}.',';
+                        foreach my $role (@rolefilter) {
+                            $filterchoice .= '&nbsp;'.$role_types{$role}.',';
                         }
                         $filterchoice =~ s/,$//;
                         $filterchoice .= '<br />&nbsp;&nbsp&nbsp;&nbsp;&nbsp;&nbsp;&nbsp&nbsp;';
@@ -901,7 +901,7 @@
 		$$visible++;
                 if ($contrib{$idx.':history'}) {
                     if ($contrib{$idx.':history'} =~ /:/) {
-                        my @oldversions = split/:/,$contrib{$idx.':history'};
+                        my @oldversions = split(/:/,$contrib{$idx.':history'});
                         $numoldver = @oldversions;
                     } else {
                         $numoldver = 1;
@@ -940,13 +940,13 @@
 
                         if ($subject eq '') {
                            if (defined($$subjectsort{'__No subject'})) {
-                               push @{$$subjectsort{'__No subject'}}, $idx;
+                               push(@{$$subjectsort{'__No subject'}}, $idx);
                            } else {
                                @{$$subjectsort{'__No subject'}} = ("$idx");
                            }
                         } else {
                             if (defined($$subjectsort{$subject})) {
-                               push @{$$subjectsort{$subject}}, $idx;
+                               push(@{$$subjectsort{$subject}}, $idx);
                             } else {
                                @{$$subjectsort{$subject}} = ("$idx");
                             }
@@ -968,7 +968,7 @@
                                 %{$$usernamesort{$contrib{$idx.':senderdomain'}}} = ();
                             }
                             if (defined($$usernamesort{$contrib{$idx.':senderdomain'}}{$contrib{$idx.':sendername'}})) {
-                                push @{$$usernamesort{$contrib{$idx.':senderdomain'}}{$contrib{$idx.':sendername'}}}, $idx;
+                                push(@{$$usernamesort{$contrib{$idx.':senderdomain'}}{$contrib{$idx.':sendername'}}}, $idx);
                             } else {
                                 @{$$usernamesort{$contrib{$idx.':senderdomain'}}{$contrib{$idx.':sendername'}}} = ("$idx");
                             }
@@ -988,7 +988,7 @@
                                 %{$$namesort{$lastname}} = ();
                             }
                             if (defined($$namesort{$lastname}{$firstname})) {
-                                push @{$$namesort{$lastname}{$firstname}}, $idx;
+                                push(@{$$namesort{$lastname}{$firstname}}, $idx);
                             } else {
                                 @{$$namesort{$lastname}{$firstname}} = ("$idx");
                             }
@@ -1044,7 +1044,7 @@
                                 %{$$usernamesort{'__anon'}} = ();
                             }
                             if (defined($$usernamesort{'__anon'}{'__anon'})) {
-                                push @{$$usernamesort{'__anon'}{'__anon'}}, $idx;
+                                push(@{$$usernamesort{'__anon'}{'__anon'}}, $idx);
                             } else {
                                 @{$$usernamesort{'__anon'}{'__anon'}} = ("$idx");
                             }
@@ -1053,7 +1053,7 @@
                                 %{$$namesort{'__anon'}} = ();
                             }
                             if (defined($$namesort{'__anon'}{'__anon'})) {
-                                push @{$$namesort{'__anon'}{'__anon'}}, $idx;
+                                push(@{$$namesort{'__anon'}{'__anon'}}, $idx);
                             } else {
                                 @{$$namesort{'__anon'}{'__anon'}} = ("$idx");
                             }
@@ -1213,7 +1213,7 @@
                                 }
                                 $$discussionitems[$idx].='<br/>'.&mt('Earlier version(s) were posted on: ');
                                 if ($contrib{$idx.':history'} =~ m/:/) {
-                                    @postversions = split/:/,$contrib{$idx.':history'};
+                                    @postversions = split(/:/,$contrib{$idx.':history'});
                                 } else {
                                     @postversions = ("$contrib{$idx.':history'}");
                                 }
@@ -1236,9 +1236,9 @@
     my $skiptest = 1;
     if (@{$rolefilter} > 0) {
         my @okrolefilter = ();
-        foreach (@{$rolefilter}) {
-            unless ($_ eq '') {
-                push @okrolefilter, $_;
+        foreach my $role (@{$rolefilter}) {
+            unless ($role eq '') {
+                push(@okrolefilter, $role);
             }
         }
         if (@okrolefilter > 0) {
@@ -1256,9 +1256,9 @@
     }
     if (@{$sectionpick} > 0) {
         my @oksectionpick = ();
-        foreach (@{$sectionpick}) {
-            unless ($_ eq '') {
-                 push @oksectionpick, $_;
+        foreach my $sec (@{$sectionpick}) {
+            unless ($sec eq '') {
+                 push(@oksectionpick, $sec);
             }
         }
         if ((@oksectionpick > 0) && (!grep/^all$/,@oksectionpick)) {
@@ -1320,7 +1320,7 @@
         }
         &get_post_versions($messages,$$contrib{$idx.':message'},1);
         &get_post_versions($subjects,$$contrib{$idx.':subject'},1);
-        push @postversions,$$contrib{$idx.':timestamp'};
+        push(@postversions,$$contrib{$idx.':timestamp'});
         $end = @postversions;
     } else {
         &get_post_versions($messages,$$contrib{$idx.':message'},1,$numver);
@@ -1348,8 +1348,8 @@
             $$imsfiles{$idx}{$i} = '';
             if ($attachmsg) {
                 $$attachtxt{$i} = '<br />'.&mt('Attachments').':<br />';
-                foreach (sort keys %currattach) {
-                    if ($$allattachments{$_}{'filename'} =~ m-^/uploaded/([^/]+/[^/]+)(/feedback)?(/?\d*)/([^/]+)$-) {
+                foreach my $key (sort(keys(%currattach))) {
+                    if ($$allattachments{$key}{'filename'} =~ m-^/uploaded/([^/]+/[^/]+)(/feedback)?(/?\d*)/([^/]+)$-) {
                         my $fname = $1.$3.'/'.$4;
                         $$imsfiles{$idx}{$i} .= '<file href="'.$fname.'">'."\n";
                         $$attachtxt{$i}.= '<a href="'.$fname.'">'.$4.'</a><br />';
@@ -1382,11 +1382,11 @@
 sub replicate_attachments {
     my ($attachrefs,$tempexport) = @_;
     my $response;
-    foreach my $id (keys %{$attachrefs}) {
+    foreach my $id (keys(%{$attachrefs})) {
         if ($$attachrefs{$id}{'filename'} =~ m-^/uploaded/([^/]+)/([^/]+)(/feedback)?(/?\d*)/([^/]+)$-) {
             my $path = $tempexport;
             my $tail = $1.'/'.$2.$4;
-            my @extras = split/\//,$tail;
+            my @extras = split(/\//,$tail);
             my $destination = $tempexport.'/'.$1.'/'.$2.$4.'/'.$5;
             if (!-e $destination) {
                 my $i= 0;
@@ -1497,7 +1497,7 @@
       unless (($contrib{'hidden'}=~/\.$idx\./) || ($contrib{'deleted'}=~/\.$idx\./)) {
           if ($contrib{$idx.':history'}) {
               if ($contrib{$idx.':history'} =~ /:/) {
-                  my @oldversions = split/:/,$contrib{$idx.':history'};
+                  my @oldversions = split(/:/,$contrib{$idx.':history'});
                   $numoldver = @oldversions;
               } else {
                   $numoldver = 1;
@@ -1506,7 +1506,7 @@
           if ($env{'form.replydisc'}) {
               if ($contrib{$idx.':history'}) {
                   if ($contrib{$idx.':history'} =~ /:/) {
-                      my @oldversions = split/:/,$contrib{$idx.':history'};
+                      my @oldversions = split(/:/,$contrib{$idx.':history'});
                       $numoldver = @oldversions;
                   } else {
                       $numoldver = 1;
@@ -1650,19 +1650,19 @@
 END
     if ( ($env{'form.editdisc'}) || ($env{'form.replydisc'}) ) {
         if ($env{'form.origpage'}) {
-            foreach (@currnewattach) {
-                $r->print('<input type="hidden" name="currnewattach" value="'.$_.'" />'."\n");
+            foreach my $attach (@currnewattach) {
+                $r->print('<input type="hidden" name="currnewattach" value="'.$attach.'" />'."\n");
             }
-            foreach (@currdelold) {
-                $r->print('<input type="hidden" name="deloldattach" value="'.$_.'" />'."\n");
+            foreach my $oldatt (@currdelold) {
+                $r->print('<input type="hidden" name="deloldattach" value="'.$oldatt.'" />'."\n");
             }
         }
         if ($env{'form.editdisc'}) {
             if ($attachmenturls) {
                 &extract_attachments($attachmenturls,$idx,$numoldver,\$attachmsg,\%attachments,\%currattach,\@currdelold);
-                $attachnum = scalar(keys %currattach);
-                foreach (keys %currattach) {
-                    $r->print('<input type="hidden" name="keepold" value="'.$_.'" />'."\n");
+                $attachnum = scalar(keys(%currattach));
+                foreach my $key (keys(%currattach)) {
+                    $r->print('<input type="hidden" name="keepold" value="'.$key.'" />'."\n");
                 }
             }
         }
@@ -2200,7 +2200,7 @@
                     $postcounts{$poster} ++;
                     if (defined($namesort{$lastname}{$firstname})) {
                         if (!grep/^$poster$/,@{$namesort{$lastname}{$firstname}}) {
-                            push @{$namesort{$lastname}{$firstname}}, $poster;
+                            push(@{$namesort{$lastname}{$firstname}}, $poster);
                         }
                     } else {
                         @{$namesort{$lastname}{$firstname}} = ("$poster");
@@ -2225,19 +2225,19 @@
       </tr>
 END
     my $count = 0;
-    foreach my $last (sort keys %namesort) {
-        foreach my $first (sort keys %{$namesort{$last}}) {
-            foreach (sort @{$namesort{$last}{$first}}) {
-                my ($uname,$udom) = split/:/,$_;
+    foreach my $last (sort(keys(%namesort))) {
+        foreach my $first (sort(keys(%{$namesort{$last}}))) {
+            foreach my $user (sort(@{$namesort{$last}{$first}})) {
+                my ($uname,$udom) = split(/:/,$user);
                 if (!$uname || !$udom) { 
                     next;
                 } else {
                     $count ++;
                     $r->print(&Apache::loncommon::start_data_table_row().
 			      '<td align="right">'.$count.'</td>
-                               <td align="center"><label><input name="stuinfo" type="checkbox" value="'.$_.'" /></td>
+                               <td align="center"><label><input name="stuinfo" type="checkbox" value="'.$user.'" /></td>
                                <td>'.$last.', '.$first.' ('.$uname.':'.$udom.')</label></td>
-                               <td>'.$postcounts{$_}.'</td>'.
+                               <td>'.$postcounts{$user}.'</td>'.
 			      &Apache::loncommon::end_data_table_row());
                 }
             }
@@ -2374,9 +2374,9 @@
           if (ref($sectionpick) eq 'ARRAY') {
               $feedurl .= '&sectionpick=';
               $sectag .=  '<input type="hidden" name="sectionpick" value="';
-              foreach (@{$sectionpick}) {
-                  $feedurl .= $_.',';
-                  $sectag .= $_.',';
+              foreach my $sec (@{$sectionpick}) {
+                  $feedurl .= $sec.',';
+                  $sectag .= $sec.',';
               }
               $feedurl =~ s/,$//;
               $sectag =~ s/,$//;
@@ -2402,9 +2402,9 @@
           if (ref($rolefilter) eq 'ARRAY') {
               $feedurl .= '&rolefilter=';
               $roletag .=  '<input type="hidden" name="rolefilter" value="';
-              foreach (@{$rolefilter}) {
-                  $feedurl .= $_.',';
-                  $roletag .= $_.',';
+              foreach my $role (@{$rolefilter}) {
+                  $feedurl .= $role.',';
+                  $roletag .= $role.',';
               }
               $feedurl =~ s/,$//;
               $roletag =~ s/,$//;
@@ -2615,9 +2615,9 @@
     $rec=~s/\@/\:/g;
     my ($adr,$sections)=($rec=~/^([^\(]+)\(([^\)]+)\)/);
     if ($sections) {
-	foreach (split(/\;/,$sections)) {
-            if (($_ eq $env{'request.course.sec'}) ||
-                ($defaultflag && ($_ eq '*'))) {
+	foreach my $sec (split(/\;/,$sections)) {
+            if (($sec eq $env{'request.course.sec'}) ||
+                ($defaultflag && ($sec eq '*'))) {
                 return $adr; 
             }
         }
@@ -2669,28 +2669,28 @@
   }
   if ($env{'form.discuss'} eq 'question' ||$question) {
     $typestyle.=&mt('Submitting as Question').'<br />';
-    foreach (split(/\,/,
+    foreach my $item (split(/\,/,
 		   $env{'course.'.$env{'request.course.id'}.'.question.email'})
 	     ) {
-	my $rec=&secapply($_,$defaultflag);
+	my $rec=&secapply($item,$defaultflag);
         if ($rec) { $to{$rec}=1; }
     } 
   }
   if ($env{'form.discuss'} eq 'course' ||$course) {
     $typestyle.=&mt('Submitting as Comment').'<br />';
-    foreach (split(/\,/,
+    foreach my $item (split(/\,/,
 		   $env{'course.'.$env{'request.course.id'}.'.comment.email'})
 	     ) {
-	my $rec=&secapply($_,$defaultflag);
+	my $rec=&secapply($item,$defaultflag);
         if ($rec) { $to{$rec}=1; }
     } 
   }
   if ($env{'form.discuss'} eq 'policy' ||$policy) {
     $typestyle.=&mt('Submitting as Policy Feedback').'<br />';
-    foreach (split(/\,/,
+    foreach my $item (split(/\,/,
 		   $env{'course.'.$env{'request.course.id'}.'.policy.email'})
 	     ) {
-	my $rec=&secapply($_,$defaultflag);
+	my $rec=&secapply($item,$defaultflag);
         if ($rec) { $to{$rec}=1; }
     } 
   }
@@ -2713,13 +2713,13 @@
   my $sendsomething=0;
   if ($title=~/^Error/) { $title=&mt('Feedback').': '.$title; }
   unless ($title=~/\w/) { $title=&mt('Feedback'); }
-  foreach (keys %to) {
-    if ($_) {
+  foreach my $key (keys(%to)) {
+    if ($key) {
       my $declutter=&Apache::lonnet::declutter($feedurl);
-      unless (&Apache::lonmsg::user_normal_msg(split(/\:/,$_),
+      unless (&Apache::lonmsg::user_normal_msg(split(/\:/,$key),
                $title.' ['.$declutter.']',$email,$citations,$feedurl,
                 $attachmenturl)=~/ok/) {
-	$status.='<br />'.&mt('Error sending message to').' '.$_.'<br />';
+	$status.='<br />'.&mt('Error sending message to').' '.$key.'<br />';
       } else {
 	$sendsomething++;
       }
@@ -2727,7 +2727,7 @@
   }
 
     my %record=&Apache::lonnet::restore('_feedback');
-    my ($temp)=keys %record;
+    my ($temp)=keys(%record);
     unless ($temp=~/^error\:/) {
        my %newrecord=();
        $newrecord{'resource'}=$feedurl;
@@ -2788,7 +2788,7 @@
             }
             if (defined($oldcontrib{$oldidx.':history'})) {
                 if ($oldcontrib{$oldidx.':history'} =~ /:/) {
-                    my @oldversions = split/:/,$oldcontrib{$oldidx.':history'};
+                    my @oldversions = split(/:/,$oldcontrib{$oldidx.':history'});
                     $numoldver = @oldversions;
                 } else {
                     $numoldver = 1;
@@ -2831,7 +2831,7 @@
 		     $env{'course.'.$env{'request.course.id'}.'.num'});
     }
     my %record=&Apache::lonnet::restore('_discussion');
-    my ($temp)=keys %record;
+    my ($temp)=keys(%record);
     unless ($temp=~/^error\:/) {
        my %newrecord=();
        $newrecord{'resource'}=$symb;
@@ -2959,7 +2959,7 @@
 END
     if ($idx) {
         if ($attachmenturls) {
-            my @currold = keys %currattach;
+            my @currold = keys(%currattach);
             if (@currold > 0) {
                 $r->print($lt{'thfo'}.'<br />'.$lt{'chth'}.'<br />'."\n");  
                 foreach my $id (@currold) {
@@ -2973,9 +2973,9 @@
     }
     if ((ref($currnewattach) eq 'ARRAY') && (@{$currnewattach} > 0)) {
         $r->print($lt{'thef'}.'<br />'.$lt{'chth'}.'<br />'."\n");
-        foreach (@{$currnewattach}) {
-            $_ =~ m#/([^/]+)$#;
-            $r->print('<label><input type="checkbox" name="delnewattach" value="'.$_.'" />&nbsp;'.$1.'</label><br />'."\n");
+        foreach my $attach (@{$currnewattach}) {
+            $attach =~ m#/([^/]+)$#;
+            $r->print('<label><input type="checkbox" name="delnewattach" value="'.$attach.'" />&nbsp;'.$1.'</label><br />'."\n");
         }
         $r->print("<br />"); 
     }
@@ -3020,14 +3020,14 @@
         my @currnew = ();
         foreach my $newone (@{$currnewattach}) {
             my $delflag = 0;
-            foreach (@currdelnew) {
-                if ($newone eq $_) {
+            foreach my $item (@currdelnew) {
+                if ($newone eq $item) {
                     $delflag = 1;
                     last;
                 }
             }
             unless ($delflag) {
-                push @currnew, $newone;
+                push(@currnew, $newone);
             }
         }
         @{$currnewattach} = @currnew;
@@ -3064,15 +3064,15 @@
 ENDATTACH
     if (defined($deloldattach)) {
         if (@{$deloldattach} > 0) {
-            foreach (@{$deloldattach}) {
-                $response .= '<input type="hidden" name="deloldattach" value="'.$_.'" />'."\n";
+            foreach my $delatt (@{$deloldattach}) {
+                $response .= '<input type="hidden" name="deloldattach" value="'.$delatt.'" />'."\n";
             }
         }
     }
     if (defined($currnewattach)) {
         if (@{$currnewattach} > 0) {
-            foreach (@{$currnewattach}) {
-                $response .= '<input type="hidden" name="currnewattach" value="'.$_.'" />'."\n";
+            foreach my $attach (@{$currnewattach}) {
+                $response .= '<input type="hidden" name="currnewattach" value="'.$attach.'" />'."\n";
             }
         }
     }
@@ -3084,7 +3084,7 @@
     my ($attachmenturls,$idx,$numoldver,$message,$attachments,$currattach,$currdelold) = @_;
     %{$attachments}=();
     &get_post_attachments($attachments,$attachmenturls);
-    foreach my $id (sort keys %{$attachments}) {
+    foreach my $id (sort(keys(%{$attachments}))) {
         if (exists($$attachments{$id}{$numoldver})) {
             if (defined($currdelold)) {
                 if (@{$currdelold} > 0) {
@@ -3099,7 +3099,7 @@
             }
         }
     }
-    my @attached = (sort { $a <=> $b } keys %{$currattach});
+    my @attached = (sort { $a <=> $b } keys(%{$currattach}));
     if (@attached == 1) {
         my $id = $attached[0];
         my $attachurl;
@@ -3115,8 +3115,8 @@
                                $attachurl);
     } elsif (@attached > 1) {
         $$message.='<ol>';
-        foreach (@attached) {
-            my $id = $_;
+        foreach my $attach (@attached) {
+            my $id = $attach;
             my $attachurl = &HTML::Entities::decode($$attachments{$id}{'filename'});
             my ($fname)
               =($attachurl=~m|/([^/]+)$|);
@@ -3143,7 +3143,7 @@
         $oldattachmenturl = $contrib{$idx.':attachmenturl'};
         if ($contrib{$idx.':history'}) {
             if ($contrib{$idx.':history'} =~ /:/) {
-                my @oldversions = split/:/,$contrib{$idx.':history'};
+                my @oldversions = split(/:/,$contrib{$idx.':history'});
                 $currver = 1 + scalar(@oldversions);
             } else {
                 $currver = 2;
@@ -3156,13 +3156,13 @@
                 my %attachments = ();
                 my $prevver = $currver-1;
                 &get_post_attachments(\%attachments,$oldattachmenturl);
-                my $numattach = scalar(keys %attachments);
+                my $numattach = scalar(keys(%attachments));
                 $startnum += $numattach;
-                foreach my $num (sort {$a <=> $b} keys %attachments) {
+                foreach my $num (sort {$a <=> $b} keys(%attachments)) {
                     $newattachmenturl .= '<attachment id="'.$num.'"><filename>'.$attachments{$num}{'filename'}.'</filename>';
-                    foreach $_ (sort {$a <=> $b} keys %{$attachments{$num}}) {
-                        unless ($_ eq 'filename') {
-                            $newattachmenturl .= '<post id="'.$_.'">'.$attachments{$num}{$_}.'</post>';
+                    foreach my $item (sort {$a <=> $b} keys(%{$attachments{$num}})) {
+                        unless ($item eq 'filename') {
+                            $newattachmenturl .= '<post id="'.$item.'">'.$attachments{$num}{$item}.'</post>';
                         }
                     }
                     if (grep/^$num$/,@{$keepold}) {
@@ -3194,7 +3194,7 @@
     foreach my $resource (@allres) {
         if ($resource->hasDiscussion()) {
             my $ressymb = $resource->wrap_symb();
-            push @{$resourcesref}, $ressymb;
+            push(@{$resourcesref}, $ressymb);
         }
     }
     return;
@@ -3256,7 +3256,7 @@
       my $readkey = $symb.'_read';
       my $chgcount = 0;
       my %readinghash = &Apache::lonnet::get('nohist_'.$env{'request.course.id'}.'_discuss',[$readkey],$env{'user.domain'},$env{'user.name'});
-      foreach my $key (keys %env) {
+      foreach my $key (keys(%env)) {
           if ($key =~ m/^form\.postunread_(\d+)/) {
               if ($readinghash{$readkey} =~ /\.$1\./) {
                   $readinghash{$readkey} =~ s/\.$1\.//;
@@ -3355,7 +3355,7 @@
       my @resources = ();
       if (defined($env{'form.navmaps'})) {
           if ($env{'form.navmaps'} =~ /:/) {
-              @resources = split/:/,$env{'form.navmaps'};
+              @resources = split(/:/,$env{'form.navmaps'});
           } else {
               @resources = ("$env{'form.navmaps'}");
           }
@@ -3370,8 +3370,8 @@
           'robb' => 'resources/bulletin boards.',
           'twnp' => 'There are currently no resources or bulletin boards with unread discussion postings.'
       );       
-      foreach (@resources) {
-          my $ressymb=$_;
+      foreach my $res (@resources) {
+          my $ressymb=$res;
 	  &Apache::lonenc::check_decrypt(\$ressymb);
           my $lastkey = $ressymb.'_lastread';
           $discinfo{$lastkey} = $env{'form.navtime'};
@@ -3541,7 +3541,7 @@
           unless (length($env{'form.addnewattach'})>131072) {
               my $subdir = 'feedback/'.$env{'form.timestamp'};
               my $newattachment=&Apache::lonnet::userfileupload('addnewattach',undef,$subdir);
-	      push @currnewattach, $newattachment;
+	      push(@currnewattach, $newattachment);
           }
       }
       my $attachmenturls;

--raeburn1164772516--