title: Perl CGI display image to browser from file
body: <p>Friends,<br>
  I have been scouring the web for a solution to displaying images to a web browser with Perl and have found nothing that works for me.<br>
  I've tried possible solutions such as:<br>
  <a href="https://stackoverflow.com/questions/8896481/how-to-display-an-image-with-perl">How To Display an Image with Perl</a><br>
  <a href="http://docstore.mik.ua/orelly/linux/cgi/ch13_02.htm" rel="nofollow noreferrer">Outputting Image Data</a><br>
  <a href="http://www.youtube.com/watch?v=BEv0iw5uxq4" rel="nofollow noreferrer">Return an Image From a Script</a><br>
  and none of it works for what I'm doing. I want to deny client access to the image (Or even simply place the image file out of the www root) and dish it out server-side. <br>
  Here is an example of what I'm doing:<br><br>
  In my main perl file:</p>
  
  <pre><code>...
  my $query = CGI-&gt;new();
  
  sub main {
  ### This grabs page content from a module, depending on the page name.
  ### The module returns the HTML.
  my $html = get_page('page', 'session');
  
  ### Perform any special conditionals here before printing the header...
  
  print $query-&gt;header(some cookie/session data here);
  print $html
  
  }
  </code></pre>
  
  <p>In one of the modules:</p>
  
  <pre><code>sub return_page_content {
  
  return &lt;&lt;HTML;
  &lt;html&gt;
    &lt;body&gt;
      &lt;img src="GET IMAGE HERE..." /&gt;
    &lt;/body&gt;
  &lt;/html&gt;
  HTML
  }
  </code></pre>
  
  <p>I've thought about just creating a copy of the image in a temp directory location, but that seems like it would defeat the entire purpose of keeping the image out of client-side access.<br>
  The probable solutions do not generate the image. I'm not sure where to go from here, so I am hoping someone here has an idea. Thank you so much!<br>
  Please let me know if I need to provide additional information. I feel like this could be beneficial to a lot of people. I hope at least ;-)</p>