Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If you want just print the array, try following code:</p> <pre><code>foreach my $row (@array) { foreach my $elem (@$row) { print $elem; ## print elements without separator } print "\n"; ## new line after row } </code></pre> <p>If you need indexes for some purpose, here we go:</p> <pre><code>for(my $row_i = 0; $row_i &lt; @array; $row_i++) { for(my $column_i = 0; $column_i &lt; @{ $array[$row_i] }; $column_i++) { print $array[$row_i][$column_i]; } } </code></pre> <p>The idea is that <code>@array</code> in <em>scalar context</em> returns number of elements in array. And <code>@{ $array[$row_i] }</code> is a little more tricky. It dereference array stored in <code>$array[$row_i]</code>.</p> <p><strong>Update for subroutine:</strong></p> <p>In perl you can pass array by reference:</p> <pre><code> printarray(\@array); ## pass reference sub printarray { my $array_ref = shift; ## no copy created foreach my $row (@$array_ref) { ## now we need to dereference ... } } </code></pre> <p>You can also pass a copy of array:</p> <pre><code> printarray(@array); sub printarray { my @array_copy = @_; ## store local copy of array ... } </code></pre> <p>For more details take a look at <a href="http://perldoc.perl.org/perlfaq7.html#How-can-I-pass%2freturn-a-%7bFunction%2c-FileHandle%2c-Array%2c-Hash%2c-Method%2c-Regex%7d%3f" rel="noreferrer">How can I pass/return a {Function, FileHandle, Array, Hash, Method, Regex}?</a> manual page.</p> <p>And please add <strong><code>use strict;</code></strong> at the begining of programm. It'll force you to declare all variables, but will save bunch of time if you type something incorrectly.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload