title: How can I process a multi line string one line at a time in perl with use strict in place?
body: <p>I'm trying to figure out the proper PBP approved way to process a multi line string one line at a time.  Many Perl coders suggest treating the multi line string as a filehandle, which works fine unless you have "use strict" in your script.  Then you get a warning from the compiler about not being able to use a string as a symbol while strict refs is in use.</p>
  
  <p>Here's a simple working example of the problem:</p>
  
  <pre><code>#use strict;
  use warnings; 
  
  my $return = `dir`;
  my $ResultsHandle = "";
  my $matchLines = "";
  my $resultLine = "";
  open $ResultsHandle, '&lt;', \$return;
  while (defined ($resultLine = &lt;$ResultsHandle&gt;)) {
      if ($resultLine =~ m/joe/) {
          $matchLines = $matchLines . "\t" . $resultLine;
      }
  }
  close($ResultsHandle);
  print "Original string: \n$return\n";
  print "Found these matching lines: \n$matchLines\n";
  </code></pre>
  
  <p>Notice that the "use strict" line is commented out.  When I run this script without use strict, I get what I want and expect:</p>
  
  <pre><code>Original string: 
   Volume in drive D has no label.
   Volume Serial Number is 50D3-54A6
  
   Directory of D:\Documents and Settings\username\My Documents\Eclipse\myTestProject
  
  09/18/2009  11:38 AM    &lt;DIR&gt;          .
  09/18/2009  11:38 AM    &lt;DIR&gt;          ..
  09/18/2009  11:36 AM               394 .project
  09/18/2009  11:37 AM                 0 joe.txt
  09/18/2009  11:37 AM                 0 joey.txt
  09/18/2009  11:38 AM                 0 kurt.txt
  09/18/2009  11:43 AM               497 main.pl
  09/18/2009  11:38 AM                 0 shane.txt
                 6 File(s)            891 bytes
                 2 Dir(s)   6,656,188,416 bytes free
  
  Found these matching lines: 
      09/18/2009  11:37 AM                 0 joe.txt
      09/18/2009  11:37 AM                 0 joey.txt
  </code></pre>
  
  <p>Here's the problem, though.  When I uncomment the "use strict" line, I get the following warning or error from Perl:</p>
  
  <pre><code>Can't use string ("") as a symbol ref while "strict refs" in use at D:/Documents and Settings/username/My Documents/Eclipse/myTestProject/main.pl line 8.
  </code></pre>
  
  <p>Line 8 is the "open $ResultsHandle, '&lt;', \$return;" line, by the way.  So since Perl Best Practices requires me to use strict, how does PBP expect me to process a multi line string one line at a time?  Any suggestions from the SO community?</p>
  
  <p>Thanks!</p>