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).