changeset 334:0a62974ff1f3 misc

Use modern [] style array definitions instead of array() in PHP output.
author Matti Hamalainen <ccr@tnsp.org>
date Thu, 31 Dec 2015 06:33:23 +0200
parents 02b421843a90
children c5c30dee4e45
files materials/parsealloys.pl materials/parsematerial.pl
diffstat 2 files changed, 25 insertions(+), 25 deletions(-) [+]
line wrap: on
line diff
--- a/materials/parsealloys.pl	Thu Dec 31 06:32:55 2015 +0200
+++ b/materials/parsealloys.pl	Thu Dec 31 06:33:23 2015 +0200
@@ -127,24 +127,24 @@
 ## Output the results
 if ($mode eq "-php")
 {
-  print "<?\n".
-  "\$alloyTable = array(\n";
+  print "<?php\n".
+  "\$alloyTable = [\n";
   
   foreach my $min1 (sort { $a cmp $b } keys %$Materials::matTable)
   {
     print "  \"$min1\" => ";
     if (scalar(keys %{$final{$min1}}) > 0)
     {
-      print "array(";
+      print "[";
       foreach my $min2 (sort { $a cmp $b } keys %{$final{$min1}})
       {
-        print "\"$min2\" => array(";
+        print "\"$min2\" => [";
         foreach my $res (sort { $final{$min1}{$min2}{$a} <=> $final{$min1}{$min2}{$b} } keys %{$final{$min1}{$min2}}) {
           print "\"$res\" => ".$final{$min1}{$min2}{$res}.", ";
         }
-        print "), ";
+        print "], ";
       }
-      print "),\n";
+      print "],\n";
     }
     else
     {
@@ -152,7 +152,7 @@
     }
   }
   
-  print ");\n\n";
+  print "];\n\n";
   
   # Create 'reverse' alloy table
   my %restab = ();
@@ -181,26 +181,26 @@
     }
   }
 
-  print "\$alloyRevTable = array(\n";
+  print "\$alloyRevTable = [\n";
   foreach my $res (sort { $a cmp $b } keys %restab)
   {
-    print "  \"$res\" => array(\n";
+    print "  \"$res\" => [\n";
     foreach my $min1 (sort { $a cmp $b } keys %{$restab{$res}})
     {
       if (scalar(keys %{$restab{$res}{$min1}}) > 0)
       {
-        print "    \"$min1\" => array(";
+        print "    \"$min1\" => [";
         foreach my $min2 (sort { $a cmp $b } keys %{$restab{$res}{$min1}})
         {
           print "\"$min2\" => ".$restab{$res}{$min1}{$min2}.",";
         }
-        print "),\n";
+        print "],\n";
       }
     }
-    print "  ),\n";
+    print "  ],\n";
   }
   
-  print ");\n\n".
+  print "];\n\n".
   "?>";
 }
 elsif ($mode eq "-text")
--- a/materials/parsematerial.pl	Thu Dec 31 06:32:55 2015 +0200
+++ b/materials/parsematerial.pl	Thu Dec 31 06:33:23 2015 +0200
@@ -690,14 +690,14 @@
 ###
 elsif ($opt_mode eq "-php")
 {
-  print "<?\n".
-  "\$matTransNames = array(".
+  print "<?php\n".
+  "\$matTransNames = [".
   join(",", map { "\"".$$_{"l"}."\"" } @fieldInfo).
-  ");\n\n".
-  "\$matTransTable = array(\n";
+  "];\n\n".
+  "\$matTransTable = [\n";
   foreach my $i (sort { $a <=> $b } keys %$transTable)
   {
-    print "  array(";
+    print "  [";
     foreach my $j (sort { $$transTable{$i}{$a} <=> $$transTable{$i}{$b} } keys %{$$transTable{$i}})
     {
       print $$transTable{$i}{$j};
@@ -705,26 +705,26 @@
       $j =~ s/incredibly /incr./;
       print " => \"".$j."\","
     }
-    print "),\n";
+    print "],\n";
   }
-  print ");\n\n".
-  "\$matDataTable = array(\n";
+  print "];\n\n".
+  "\$matDataTable = [\n";
   foreach my $name (sort { $a cmp $b } keys %$data)
   {
-    print "  \"$name\" => array(";
+    print "  \"$name\" => [";
     for (my $qn = 1; $qn < scalar(@fieldInfo); $qn++)
     {
       my $i = $fieldInfo[$qn]{"i"};
       if (ref($$data{$name}{$i}) eq "ARRAY")
       {
-        print "array(".join(",", @{$$data{$name}{$i}})."),";
+        print "[".join(",", @{$$data{$name}{$i}})."],";
       }
       else
       {
         print $$data{$name}{$i}.", ";
       }
     }
-    print "),\n";
+    print "],\n";
   }
-  print ");\n?>\n";
+  print "];\n?>\n";
 }