[LON-CAPA-cvs] cvs: rat / lonuserstate.pm

albertel lon-capa-cvs@mail.lon-capa.org
Thu, 23 Feb 2006 18:08:43 -0000


albertel		Thu Feb 23 13:08:43 2006 EDT

  Modified files:              
    /rat	lonuserstate.pm 
  Log:
  - killing some usages of $_
  - some style hanges
  
  
Index: rat/lonuserstate.pm
diff -u rat/lonuserstate.pm:1.103 rat/lonuserstate.pm:1.104
--- rat/lonuserstate.pm:1.103	Wed Feb 22 18:44:55 2006
+++ rat/lonuserstate.pm	Thu Feb 23 13:08:43 2006
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Construct and maintain state and binary representation of course for user
 #
-# $Id: lonuserstate.pm,v 1.103 2006/02/22 23:44:55 albertel Exp $
+# $Id: lonuserstate.pm,v 1.104 2006/02/23 18:08:43 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -406,12 +406,11 @@
     my %captured=();
     my $condcounter=0;
     $acchash{'acc.cond.'.$short.'.0'}=0;
-    foreach (keys %hash) {
-	if ($_=~/^conditions/) {
-	    my $expr=$hash{$_};
-	    foreach ($expr=~m/(\(\(\d+(?:\&\d+)+\)(?:\|\(\d+(?:\&\d+)+\))+\))/g) {
-		my $sub=$_;
-		my $orig=$_;
+    foreach my $key (keys(%hash)) {
+	if ($key=~/^conditions/) {
+	    my $expr=$hash{$key};
+	    foreach my $sub ($expr=~m/(\(\(\d+(?:\&\d+)+\)(?:\|\(\d+(?:\&\d+)+\))+\))/g) {
+		my $orig=$sub;
 		$sub=~/\(\((\d+\&(:?\d+\&)*)(?:\d+\&*)+\)(?:\|\(\1(?:\d+\&*)+\))+\)/;
 		my $factor=$1;
 		$sub=~s/$factor//g;
@@ -421,17 +420,17 @@
 		$orig=~s/(\W)/\\$1/g;
 		$expr=~s/$orig/$sub/;
 	    }
-	    $hash{$_}=$expr;
+	    $hash{$key}=$expr;
 	    unless (defined($captured{$expr})) {
 		$condcounter++;
 		$captured{$expr}=$condcounter;
 		$acchash{'acc.cond.'.$short.'.'.$condcounter}=$expr;
 	    } 
-	} elsif ($_=~/^param_(\d+)\.(\d+)/) {
+	} elsif ($key=~/^param_(\d+)\.(\d+)/) {
 	    my $prefix=&Apache::lonnet::encode_symb($hash{'map_id_'.$1},$2,
 						    $hash{'src_'.$1.'.'.$2});
-	    foreach (split(/\&/,$hash{$_})) {
-		my ($typename,$value)=split(/\=/,$_);
+	    foreach my $param (split(/\&/,$hash{$key})) {
+		my ($typename,$value)=split(/\=/,$param);
 		my ($type,$name)=split(/\:/,$typename);
 		$parmhash{$prefix.'.'.&Apache::lonnet::unescape($name)}=
 		    &Apache::lonnet::unescape($value);
@@ -440,10 +439,9 @@
 	    }
 	}
     }
-    foreach (keys %hash) {
-	if ($_=~/^ids/) {
-	    foreach (split(/\,/,$hash{$_})) {
-		my $resid=$_;
+    foreach my $key (keys(%hash)) {
+	if ($key=~/^ids/) {
+	    foreach my $resid (split(/\,/,$hash{$key})) {
 		my $uri=$hash{'src_'.$resid};
 		my ($uripath,$urifile) =
 		    &Apache::lonnet::split_uri_for_cond($uri);
@@ -458,8 +456,8 @@
 			    my $replace=$1;
 			    my $regexp=$replace;
 			    #$regexp=~s/\|/\\\|/g;
-			    $acchash{'acc.res.'.$short.'.'.$uripath}
-			    =~s/\Q$regexp\E/$replace\|$uricond/;
+			    $acchash{'acc.res.'.$short.'.'.$uripath}=~
+				s/\Q$regexp\E/$replace\|$uricond/;
 			} else {
 			    $acchash{'acc.res.'.$short.'.'.$uripath}.=
 				$urifile.':'.$uricond.'&';