For those with time on their hands,

Try your hand at something relatively un-perl-ish with Perl like, for example, reading and writing bitmap images directly in Perl, without the aid of modules such as Image::Magick or GD.

For example, say you wanted to read the header data from a Windows Bitmap file:

(see http://msdn2.microsoft.com/en-us/library/ms532301%28VS.85%29.aspx)

use strict; use Fcntl; my %headers = ( 0 => "file-type", 1 => "file-size-in-bytes", 2 => "must-be-0", 3 => "must-be-0", 4 => "offset-to-raster-in-bytes", 5 => "size-of-following-header-in-bytes", 6 => "width-in-pixels", 7 => "height-in-pixels", 8 => "device-planes", 9 => "bits-per-pixel", 10 => "type-of-compression", 11 => "raster-size-in-bytes", 12 => "horizontal-pixels-per-meter", 13 => "vertical-pixels-per-meter", 14 => "number-of-colors-used", 15 => "number-of-important-colors", ); my $x = binary_contents("path/to/bitmap.bmp"); my @x = bmp_headers($x); for my $i(0..$#x){ printf "%-5s %-10s %-20s\n",$i,$x[$i],$headers{$i} } sub bmp_headers { # careful - 's' is endian sensitive my $t = 'a2Vn2V4s2V6'; my $x = shift; unpack($t,$x); } sub binary_contents { my $g = shift; sysopen(my $F, $g, O_RDONLY) or die "cant open: $g\n$!\n"; sysread($F, my $x, -s($g)); close $F; return $x; }
If you read up on Bitmap Structs, you can read in and parse any MCSF Bitmaps (through Version 5). From there, try writing your own bitmaps with pack and syswrite or
open(my $FH, '>:raw', 'path/to/my/new/cool/bitmap.bmp'); print $FH $my_carefully_packed_binary_data
If you want a real challenge, try implementing your own graphics processing algorithms, like applying filters, contrasting, histogram normalization, etc... Try making it As Fast As C. (You can get very, very, close in Pure Perl).

In reply to On Challenging Ways to Learn Perl by mobiusinversion

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.