title: Obtaining lines from an array and stopping at a particular character
body: <p>I'm looking for some assistance on a script which can go through the lines of an array, printing them to the screen and stopping when the script detects a specific character, in this case the <code>!</code> mark. I have tried using the <code>foreach</code> statement but ain't getting any success...</p>
  
  <p>Example of the Array (<code>@lines</code>) contents is:</p>
  
  <pre><code>ip vrf test
  rd 2856:10000331
  export map SetAltMgmtRT
  route-target export 2856:10000331
  route-target import 2856:10000331
  maximum routes 1000 75
  !
  </code></pre>
  
  <p>The script I have so far is:</p>
  
  <pre><code>elsif ( $action eq "show_vrf" ) {
              my $cmd = "show run | begin &lt;VRF_NAME&gt;";
              $cmd = $cmd . " | i $include" if($include) ;
              my @lines = $s-&gt;cmd(String =&gt; $cmd,
                              Prompt  =&gt; "/$enableprompt/",
                              Timeout =&gt; 10);
              foreach $lines (@lines) {
                      &lt;statement, this is where I am stuck&gt;
              }
              print $lines;
  </code></pre>
  
  <p>Any help would be appreciated :)</p>