looping over the lines of a file spliiting each line in columns and creating an array of each column <p>Sorry if my question is too obvious, I´m new in perl.</p> <p>My code is the following:</p> <pre><code>open (FILE1, "$ARG[0]") or die @lines1; $i=1; while (&lt;FILE&gt;) { chomp; push (@lines1, $_); my @{columns$1}= split (/\s+/, $lines1[$i]); $i++; } </code></pre> <p>It gives an error saying </p> <pre><code>Can´t declare array dereference at the line my @{columns$1}= split (/\s+/, $lines1[$i]); </code></pre> <p>I wanted to create columns1, columns2, columns3... and each one of them would have the columns of the corresponding line (columns1 of the line 1, columns2 of line 2 and so on...) </p> <p>Because before I tried to do it this way (below) and every time it was splitting the lines but it was overwriting the @columns1 array so only the last line was saved, at the end I had the values of the 10th line (because it starting counting at 0) </p> <pre><code>for my $i (0..9) { @columns1 = split (/\s+/, $lines1[$i]); } </code></pre>