Hi all,

If I've got a scalar $data containing some binary data (a JPG image read using read_file($file, binmode => ':raw' ), how can I cause one of my routes to output it?

I've done essentially this (simplified):

get '/some/route' => sub {
  my $data = …get_image…;

  header 'Content-Type' => 'image/jpeg';
  return $data;
}

but this doesn't feel right and causes a broken output (appears to return only a few rows of pixels of the image).    

Any tips?

Cheers

-- 
Rik Brown
http://www.rikbrown.co.uk