title: Reversing array using array name and reference to array
body: <p>I have declared an array, and a reference to that array like this: -</p>
  
  <pre><code>my @array = (1, 2, 3, 4);
  my $aref = \@array;
  </code></pre>
  
  <p>Now, I'm trying to reverse the array, using the array name and the reference name.</p>
  
  <pre><code>print reverse @array, "\n";
  print reverse @{$aref}, "\n";
  </code></pre>
  
  <p>This is working fine, and printing the reversed array in both the cases: -</p>
  
  <pre><code>4321
  4321
  </code></pre>
  
  <p>However, if I try to print the reverse in the same line, its giving me a strange result: -</p>
  
  <pre><code>print reverse @array, reverse @{$aref}, "\n";
  </code></pre>
  
  <p>Now, I got this output: -</p>
  
  <pre><code>1234
  4321
  </code></pre>
  
  <p>and if I add a newline in between: -</p>
  
  <pre><code>print reverse @array, "\n", reverse @{$aref}, "\n";
  </code></pre>
  
  <p>I got this output: -</p>
  
  <pre><code>1234
  
  4321
  </code></pre>
  
  <p><strong>So, there are two problems as you can see: -</strong></p>
  
  <ul>
  <li><strong>1st,</strong> The array is not getting reversed for using the name</li>
  <li><strong>2nd,</strong> there is an extra newline getting printed between the two reversed array.</li>
  </ul>
  
  <p>I can't understand this behaviour, why this could be happening. Also I went through the documentation of the function <code>reverse</code> to check whether there is mentioned any where about this behaviour, but I didn't dine any. Can anyone explain what's happening here?</p>