-my @ch = split //, " .:coO@";
-while (<$pgm>) {
- print $ch[ $_ * @ch >> 8 ] for /\d+/g;
- print $info[$. - 4], $/;
+if (<$pgm> eq "P2\n") {
+ my ($width, $height) = split ' ', <$pgm>;
+ <$pgm>; # ignore depth
+ my @ch = split //, " .:oO@";
+ while (<$pgm>) {
+ print $ch[ $_ * @ch >> 8 ] for /\d+/g;
+ print ' ', shift @info if @info;
+ print $/;
+ }
+ substr $_, 0, 0, ' ' x ($width + 1) for @info;