title: How can I grep a paragraph in Perl?
body: <p>I have a log file which needs to be properly formatted into a readable format. However the text file has no static number of lines or fixed primary values and has random number of spaces but has only a log file header which can be used to pin point the start and end of each time the application logs.</p>
  
  <p>An Example of the log file:</p>
  
  <pre><code>Log File header
  &lt;text&gt;
  &lt;text&gt;
  Log File header
  &lt;text&gt;
  </code></pre>
  
  <p>After the script has been formatted it should look something like this:</p>
  
  <pre><code>Log File header
  &lt;text&gt;
  &lt;text&gt;
  
  &lt;space&gt;
  
  Log File header
  &lt;text&gt;
  &lt;text&gt;
  </code></pre>
  
  <p>Therefore I need some advice on greping out an entire paragraph everytime the Perl Script detects a "Log File header".</p>
  
  <p>Here is the grep perl script:</p>
  
  <pre><code>#!/usr/bin/perl
  
  #use 5.010; # must be present to import the new 5.10 functions, notice 
  #that it is 5.010 not 5.10
  
  my $file = "/root/Desktop/Logfiles.log";
  open LOG, $file or die "The file $file has the error of:\n =&gt;  $!";
  
  @lines = &lt;LOG&gt;;
  close (LOG);
  
  @array = grep(/Log File header/, @lines);
  
  print @array;
  </code></pre>
  
  <p>Can someone please give some advice on the codes? Thanks.</p>