fork(1) download
  1. #!/usr/bin/perl
  2. # your code goes here
  3.  
  4. print "Start\n";
  5. $num_ports = 3;
  6. $log2_ports;
  7. my @multi_array = ();
  8. push @multi_array, ([0,1,"2"]);
  9. push @multi_array, ([10,11,"22"]);
  10. push @multi_array, ([100,111,"222"]);
  11.  
  12. $size_m1 = scalar (@multi_array) - 1;
  13.  
  14. print "First Loop\n";
  15. foreach $i (0..$size_m1){
  16. print "Row $i : $multi_array[$i] \n";
  17. }
  18. print "Second Loop\n";
  19. foreach $i (0..$size_m1){
  20. foreach $j (0..2){
  21. $val_times_2 = $multi_array[$i][$j] * 3;
  22. print "Row $i, Column $j: $multi_array[$i][$j] and $val_times_2 \n";
  23. }
  24. }
  25. print "Third Loop\n";
  26. foreach $i (0..2){
  27. print "Row $i : $multi_array[$i] \n";
  28. }
  29. print "Fourth Loop\n";
  30. foreach $i (0..2){
  31. foreach $j (0..2){
  32. print "Row $i, Column $j: $multi_array[$i][$j] \n";
  33. }
  34. }
  35.  
  36. #print $num_ports;
  37. #print $log2_ports;
  38. print "Done";
Success #stdin #stdout 0s 5268KB
stdin
Standard input is empty
stdout
Start
First Loop
Row 0 : ARRAY(0x5642e3b09278) 
Row 1 : ARRAY(0x5642e3b2bd80) 
Row 2 : ARRAY(0x5642e3b2bed0) 
Second Loop
Row 0, Column 0: 0  and 0 
Row 0, Column 1: 1  and 3 
Row 0, Column 2: 2  and 6 
Row 1, Column 0: 10  and 30 
Row 1, Column 1: 11  and 33 
Row 1, Column 2: 22  and 66 
Row 2, Column 0: 100  and 300 
Row 2, Column 1: 111  and 333 
Row 2, Column 2: 222  and 666 
Third Loop
Row 0 : ARRAY(0x5642e3b09278) 
Row 1 : ARRAY(0x5642e3b2bd80) 
Row 2 : ARRAY(0x5642e3b2bed0) 
Fourth Loop
Row 0, Column 0: 0 
Row 0, Column 1: 1 
Row 0, Column 2: 2 
Row 1, Column 0: 10 
Row 1, Column 1: 11 
Row 1, Column 2: 22 
Row 2, Column 0: 100 
Row 2, Column 1: 111 
Row 2, Column 2: 222 
Done