title: cannot print out variable called from perl sub routine
body: <p>I want to convert my foreach loop to a sub routine <code>sub mybits</code>. I'm sure I am not calling this properly or for that matter setting it up as a sub. </p>
  
  <p>What I want to do is return a value from the sub routine which is any one of three variables which i tested foreach part and am able to get data.</p>
  
  <p>Got this mesg. I am using strict, warnings: <code>Can't modify non-lvalue subroutine call</code></p>
  
  <p>How do I call this sub routine to get either of my variables <code>($dir, $fname, $fsize)</code>?</p>
  
  <p><strong>Code:</strong></p>
  
  <pre><code>my $out;
  mybits (my $dir)=$out;
  print mybits($dir);
  print "This is mybits: $out\n";
  
  
  sub mybits 
  {
      foreach my $file( @{ $data-&gt;{file} } )
      {
          #my( $dir, $fname );
          my( $dir, $fname, $fsize );
          if( $file-&gt;{path} =~ /^(.*)\/([^\/]+)$/ )
          {
              $dir = $1;
              $fname = $2;
              $fsize = $file-&gt;{size};
          }
          else
          {
              $dir = "";
              $fname = $file-&gt;{path};
          }
          #print "This is the DIRECTORY: $dir\n";
          #print "This is the FILE:      $fname\n";
          #print "This is the FILE SIZE: $fsize\n";
      }
  
  }
  </code></pre>