Do you often find yourself inteviewing someone for your next big perl project and just can't tell how good is he?

If so, this code is for you!
It uses the most sophisticated computer vision techniques. All you need to do is supply the program with a picture of the person in question.

Run this code with a picture of the candidate, and see if he is Just Another Perl Hacker or not.

Be warned! this code uses hyper-trancedental ether waves to make the psychologycal analysis.

Usage: JAPHoto.pl candidate.ppm out.ppm
(sorry, only .ppm is supported. Use 'convert candidate.jpg candidate.ppm' or 'xv' to convert it)
output image is optional, just to support the analysis :)

For example:
>JAPHoto.pl merlyn.ppm
This is a 8-hacker!
Perl is 8.78% of his personality

How much do you get? Enjoy!

#!/usr/bin/perl -w my ($image, $h, $w)=&load_ppm($ARGV[0]); my $s=3*$h*$w; my @A=unpack("C$s", $image); my $l="AnREaHTtEePZahPZcarJsWPZ"; my $p=0; my $i; $l=~tr/PoZuTsEcRalnAeJhMHktrW/eMrEnctls ZuJhaPTARoHk/; for($i=0; $i<$s-3; $i++) { if(chr($A[$i]) eq substr($l, $p%24, 1)) { my $i=$i - $i%3; print substr($l, $p%24, 1); #chr($l[$p]); $p++; $A[$i] = $A[$i]>127?0:255; $i++; $A[$i] = $A[$i]>127?0:255; $i++; $A[$i] = $A[$i]>127?0:255; } } printf "\nThis is a %d-hacker!\nPerl is %.2f%% of his personality\n", int($p/24), 100*$p/$s*3*24; if ($ARGV[1]) { $image = pack("C$s", @A); &write_ppm($ARGV[1], $image, $h, $w); } 0; # Thanks to Corion,jcwren,tilly sub load_ppm { my $name=shift || die; my $image; open(F, "<$name") || die; $_=<F>; die "$name is not a PPM file, (header=$_)\n" unless($_ eq "P6\n"); do { $_=<F> } while ( m/^\#/ ); # skip comments my ($w, $h) = m/(\d+)\D+(\d+)/; $_=<F>; die "Can't deal with this type of PPM\n" unless ($_==255); binmode(F); # just in case $_=read(F, $image, 3*$h*$w) or die; close(F); return ($image, $h, $w); } sub write_ppm { my ($name, $image, $h, $w) = @_; open(F, ">$name") or die; binmode F; $_=sprintf "P6\n$w $h\n255\n"; print F "$_$image"; close(F); }
(THIS what happens when you work on weekends :)
Seriously though, it's been a while that i wanted to write some image-processing code with perl, mostly for fun, and this code can be used to input/output images fairly efficiently for further processing.

In reply to JAPHoto.pl! by fundflow

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.