fork download
  1. #!/usr/bin/perl
  2. # your code goes here
  3. use feature qw<say>;
  4. use Data::Dumper;
  5.  
  6. print "Start\n";
  7. $num_ports = 3;
  8. $log2_ports;
  9. my @arr = ();
  10. my @arr1 = ();
  11. my @arr2 = ("1","2","3");
  12. my @arr3 = ("a","b","c");
  13.  
  14. while ($num_ports > 0) {
  15. $num_ports = $num_ports >> 1;
  16. $log2_ports++;
  17. }
  18.  
  19. foreach $i (3..0){
  20. print "Loop\n";
  21. $port_i_en = 1 << $i;
  22. print "Port enable: $port_i_en \n";
  23. }
  24.  
  25. foreach $i (0..3){
  26. print "Second Loop $i \n";
  27. push @arr, (($i > 1) ? $i * 10 : $i);
  28. }
  29.  
  30. print join(", ", @arr);
  31. #print $num_ports;
  32. #print $log2_ports;
  33.  
  34. push (@arr1, @arr2);
  35. push (@arr1, \@arr3);
  36. print "Array 1: \n";
  37. print @arr1;
  38. print "Array 2: \n";
  39. print @arr2;
  40. print "Array 3: \n";
  41. print @arr3;
  42. print "Data Dump \n";
  43. say Dumper(\@arr1);
  44. print "Done";
Success #stdin #stdout 0.02s 6756KB
stdin
Standard input is empty
stdout
Start
Second Loop 0 
Second Loop 1 
Second Loop 2 
Second Loop 3 
0, 1, 20, 30Array 1: 
123ARRAY(0x55b1eafeea08)Array 2: 
123Array 3: 
abcData Dump 
$VAR1 = [
          '1',
          '2',
          '3',
          [
            'a',
            'b',
            'c'
          ]
        ];

Done