title: Matching multiline string in file using perl regex
body: <p>I am reading in another perl file and trying to find all strings surrounded by quotations within the file, single or multiline. I've matched all the single lines fine but I can't match the mulitlines without printing the entire line out, when I just want the string itself. For example, heres a snippet of what I'm reading in:</p>
  
  <pre><code>#!/usr/bin/env perl
  use warnings;
  use strict;
  
  # assign variable
  
  my $string = 'Hello World!';
  my $string4 = "chmod";
  my $string3 = "This is a fun 
      multiple line string, please match";
  </code></pre>
  
  <p>so the output I'd like is </p>
  
  <pre><code>'Hello World!';
  "chmod";
  "This is a fun multiple line string, please match";
  </code></pre>
  
  <p>but I am getting: </p>
  
  <pre><code>'Hello World!';
  my $string4 = "chmod";
  my $string3 = "This is a fun 
      multiple line string, please match";
  </code></pre>
  
  <p>This is the code I am using to find the strings - all file content is stored in @contents:</p>
  
  <pre><code>my @strings_found = ();
  my $line; 
  for(@contents) {
      $line .= $_;
  }
  
  if($line =~ /(['"](.?)*["'])/s) {
      push @strings_found,$1;
  }
  
  print @strings_found;
  </code></pre>
  
  <p>I am guessing I am only getting 'Hello World!'; correctly because I am using the $1 but I am not sure how else to find the others without looping line by line, which I would think would make it hard to find the multi line string as it doesn't know what the next line is.</p>
  
  <p>I know my regex is reasonably basic and doesn't account for some caveats but I just wanted to get the basic catch most regex working before moving on to more complex situations.</p>
  
  <p>Any pointers as to where I am going wrong?</p>