[LON-CAPA-cvs] cvs: loncom /imspackages imsprocessor.pm

raeburn raeburn at source.lon-capa.org
Wed May 2 15:34:58 EDT 2018


raeburn		Wed May  2 19:34:58 2018 EDT

  Modified files:              
    /loncom/imspackages	imsprocessor.pm 
  Log:
  - Use three-argument open() to separate file mode from the filename.
  
  
Index: loncom/imspackages/imsprocessor.pm
diff -u loncom/imspackages/imsprocessor.pm:1.57 loncom/imspackages/imsprocessor.pm:1.58
--- loncom/imspackages/imsprocessor.pm:1.57	Wed May  2 17:08:40 2018
+++ loncom/imspackages/imsprocessor.pm	Wed May  2 19:34:58 2018
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Processor for IMS Packages
 #
-# $Id: imsprocessor.pm,v 1.57 2018/05/02 17:08:40 raeburn Exp $
+# $Id: imsprocessor.pm,v 1.58 2018/05/02 19:34:58 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -994,10 +994,10 @@
                 $seqtext{$key} .= "</map>\n";
                 if ($cms eq 'webctce4' && $key ne 'Top') {
                     push @{$seqfiles}, "$seqtitle.sequence";
-                    open(LOCFILE,">$destdir/sequences/$seqtitle.sequence");
+                    open(LOCFILE,'>',"$destdir/sequences/$seqtitle.sequence");
                 } else {
                     push @{$seqfiles}, "$key.sequence";
-                    open(LOCFILE,">$destdir/sequences/$key.sequence");
+                    open(LOCFILE,'>',"$destdir/sequences/$key.sequence");
                 }
                 print LOCFILE $seqtext{$key};
                 close(LOCFILE);
@@ -1027,7 +1027,7 @@
             &process_specials($context,'pools',$pools,\$topnum,$$items{'Top'}{contentscount},$destdir,$udom,$uname,$cdom,$crs,$timenow,$newdir,$timestamp,$resinfo,\$seqtext{'Top'},$pagesfiles,$seqfiles,$topurls,$topnames);
         }
         $seqtext{'Top'} .= "</map>\n";
-        open(TOPFILE,">$destdir/sequences/Top.sequence");
+        open(TOPFILE,'>',"$destdir/sequences/Top.sequence");
         print TOPFILE $seqtext{'Top'};
         close(TOPFILE);
         push @{$seqfiles}, 'Top.sequence';
@@ -1049,7 +1049,7 @@
             if (grep/^$res$/,@{$packages}) {
                 $resource =  $filestem.'/resfiles/'.$res.'./index.html'; # should be entry_point
             }
-            open(PAGEFILE,">$filename");
+            open(PAGEFILE,'>',$filename);
             print PAGEFILE qq|<map>
 <resource src="$resource" id="1" type="start" title="$$items{$pagecontents{$key}[$i][0]}{title}"></resource>
 <link to="2" index="1" from="1">\n|;
@@ -1238,10 +1238,10 @@
 
     if ($type eq "announcements") {
         push @{$pagesfiles}, "$seqnames{$type}.page";
-        open(ITEM,">$destdir/pages/$seqnames{$type}.page");
+        open(ITEM,'>',"$destdir/pages/$seqnames{$type}.page");
     } else {
         push @{$seqfiles}, "$seqnames{$type}.sequence";
-        open(ITEM,">$destdir/sequences/$seqnames{$type}.sequence");
+        open(ITEM,'>',"$destdir/sequences/$seqnames{$type}.sequence");
     }
 
     if ($type eq 'boards') {
@@ -1584,7 +1584,7 @@
   </tr>
 </table>
     |;
-    open(FILE,">$destdir/resfiles/$res.html");
+    open(FILE,'>',"$destdir/resfiles/$res.html");
     push @{$resrcfiles}, "$res.html";
     print FILE qq|<html>
 <head>
@@ -1663,7 +1663,7 @@
         $linktag .= qq|>$$settings{title}</a>|;
     }
 
-    open(FILE,">$destdir/resfiles/$res.html");
+    open(FILE,'>',"$destdir/resfiles/$res.html");
     push @{$resrcfiles}, "$res.html";
     print FILE qq|<html>
 <head>
@@ -3399,7 +3399,7 @@
     my $curr_id = 0;
     my $next_id = 1;
     my $fh;
-    open($fh,">$destdir/sequences/question_database.sequence");
+    open($fh,'>',"$destdir/sequences/question_database.sequence");
     push @{$sequencesfiles},'question_database.sequence';
     foreach my $category (sort(keys(%{$catinfo}))) {
         my $seqname;
@@ -3465,7 +3465,7 @@
         if (!-e "$seqdir") {
             mkdir("$seqdir",0770);
         }
-        open($fh,">$$containerdir");
+        open($fh,'>',$$containerdir);
         $$total{seq} ++;
         push @{$sequencesfiles},$mapname.'.sequence';
     } else {
@@ -3473,7 +3473,7 @@
         if (!-e "$pagedir") {
             mkdir("$pagedir",0770);
         }
-        open($fh,">$$containerdir");
+        open($fh,'>',$$containerdir);
         $$total{page} ++;
         push @{$pagesfiles},$mapname.'.page';
     }
@@ -3931,7 +3931,7 @@
             $title =~ s/\s/_/g;
             $title =~ s/\W//g;
             $title .= '_'.$id;
-            open(PROB,">$newdir/$title.problem");
+            open(PROB,'>',"$newdir/$title.problem");
             print PROB $output;
             close PROB;
         } else {
@@ -4549,7 +4549,7 @@
             $title =~ s/\s/_/g;
             $title =~ s/:/_/g;
             $title =~ s/\//_/g;
-            open(PROB,">$destdir/problems/$probdir/$title.problem");
+            open(PROB,'>',"$destdir/problems/$probdir/$title.problem");
             print PROB $output;
             close PROB;
         } else {
@@ -4948,7 +4948,7 @@
             $title =~ s/\s/_/g;
             $title =~ s/\W//g;
             $title .= '_'.$id;
-            open(PROB,">$newdir/$title.problem");
+            open(PROB,'>',"$newdir/$title.problem");
             print PROB $output;
             close PROB;
         } else {
@@ -4974,7 +4974,7 @@
         if (!-e "$docroot/$res/webimages") {
             mkdir("$docroot/$res/webimages",0755);
         }
-        open(my $fh,">$docroot/$res/webimages/$filename");
+        open(my $fh,'>',"$docroot/$res/webimages/$filename");
         print $fh $contents;
         close($fh);
         if ($context eq 'DOCS') {
@@ -5067,7 +5067,7 @@
         }
     }
 
-    open(FILE,">$destdir/resfiles/$res.html");
+    open(FILE,'>',"$destdir/resfiles/$res.html");
     push @{$resrcfiles}, "$res.html";
     print FILE qq|<html>
 <head>
@@ -5273,7 +5273,7 @@
         }
     }
 
-    if (!open(FILE,">$destdir/resfiles/$res.html")) {
+    if (!open(FILE,'>',"$destdir/resfiles/$res.html")) {
         &Apache::lonnet::logthis("IMS import error: Cannot open file - $destdir/resfiles/$res.html - $!");
     } else {
         push @{$resrcfiles}, "$res.html";
@@ -5466,7 +5466,7 @@
     $p->parse_file($xmlfile);
     $p->eof;
     if ($type eq "PAGE") {
-        open(FILE,"<$xmlfile");
+        open(FILE,'<',$xmlfile);
         @buffer = <FILE>;
         close(FILE);
         chomp(@buffer);
@@ -5483,7 +5483,7 @@
             }
         }
     }
-    open(FILE,">$destdir/resfiles/$res.html");
+    open(FILE,'>',"$destdir/resfiles/$res.html");
     push @{$resrcfiles}, "$res.html";
     print FILE qq|<html>
 <head>
@@ -5519,7 +5519,7 @@
 sub webct4_content {
     my ($res,$docroot,$destdir,$settings,$dom,$user,$type,$title,$resrcfiles) = @_;
     if (defined($$settings{url})) {
-        if (!open(FILE,">$destdir/resfiles/$res.html")) {
+        if (!open(FILE,'>',"$destdir/resfiles/$res.html")) {
             &Apache::lonnet::logthis("IMS import error: Cannot open file - $destdir/resfiles/$res.html - $!");
         } else {
             push(@{$resrcfiles}, "$res.html");




More information about the LON-CAPA-cvs mailing list