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

albertel lon-capa-cvs@mail.lon-capa.org
Tue, 05 Dec 2006 01:36:13 -0000


albertel		Mon Dec  4 20:36:13 2006 EDT

  Modified files:              
    /loncom/interface	lonclonecourse.pm 
  Log:
  - using \Q \E rather than [^\W] style escaping
  
  
Index: loncom/interface/lonclonecourse.pm
diff -u loncom/interface/lonclonecourse.pm:1.1 loncom/interface/lonclonecourse.pm:1.2
--- loncom/interface/lonclonecourse.pm:1.1	Fri Aug 11 18:00:08 2006
+++ loncom/interface/lonclonecourse.pm	Mon Dec  4 20:36:13 2006
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # routines for clone a course
 #
-# $Id: lonclonecourse.pm,v 1.1 2006/08/11 22:00:08 albertel Exp $
+# $Id: lonclonecourse.pm,v 1.2 2006/12/05 01:36:13 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -92,11 +92,9 @@
 
 sub rewritefile {
     my ($contents,%rewritehash)=@_;
-    foreach (keys %rewritehash) {
-	my $pattern=$_;
-	$pattern=~s/(\W)/\\$1/gs;
-	my $new=$rewritehash{$_};
-	$contents=~s/$pattern/$new/gs;
+    foreach my $pattern (keys(%rewritehash)) {
+	my $new=$rewritehash{$pattern};
+	$contents=~s/\Q$pattern\E/$new/gs;
     }
     return $contents;
 }
@@ -180,12 +178,11 @@
     }
 # adjust symbs
     my $pattern='uploaded/'.$origcrsdata{'domain'}.'/'.$origcrsdata{'num'}.'/';
-    $pattern=~s/(\W)/\\$1/gs;
     my $new=    'uploaded/'. $newcrsdata{'domain'}.'/'. $newcrsdata{'num'}.'/';
     foreach (keys %data) {
-	if ($_=~/$pattern/) {
+	if ($_=~/\Q$pattern\E/) {
 	    my $newkey=$_;
-	    $newkey=~s/$pattern/$new/;
+	    $newkey=~s/\Q$pattern\E/$new/;
 	    $data{$newkey}=$data{$_};
 	    delete $data{$_};
 	}