You use my $xpm two times, I think one of that lines should be commented out.
In different to the createBitmap method you do not need to put a @ in front of the image name when using createImage, if I understand "Mastering Perl/TK" the right way.
Perhaps try one of the built in bitmaps first, to be shure to have no problems with the bitmap file, e.g. my $xpm = $drawing->createBitmap(0, 0, -bitmap => 'info');.
In case of the createImage method, you have to use an object created with the Photo or Bitmap methods.
I tested a little bit and ending with this, perhaps it is a source for an idea for you:
#!/usr/bin/perl
use strict;
use warnings;
use Tk;
my $mw = new MainWindow;
$mw->geometry('600x600+110+110');
my $drawing = $mw->Canvas(
-width => 500,
-height => 500,
-background => 'white',
)->pack();
my $xpm = <<'END';
/* XPM */
static char *test[]={
"32 32 11 1",
". c None",
"# c #000000",
"h c #004000",
"g c #004040",
"f c #404000",
"e c #808080",
"i c #a0a0a4",
"c c #c0c000",
"d c #ffff00",
"b c #ffffc0",
"a c #ffffff",
"................................",
"................................",
"................................",
"................................",
".............#....###...........",
"............#a##.#aba##.........",
"...........#aaaa#aaaaaa##.......",
"..........#aaaa#aaaaaaaba##.....",
".........#aaaa#aaaaaaaaaaab##...",
"........#aaba#aaaaaaabaabaaaa##.",
".......#aaba#baaaaa#baaaaaabaaa#",
"......#aaaa#aaaaab#a##baaaaaaa#.",
".....#aaba#aacbba#aaaa##baaab#..",
"....#bbaa#abaacc#aaaaaaa##aa#...",
"...#bbbb#aaabaa#aaabaaaaaa##....",
"..#bbbb#bacaaa#aaaaaaaabaaaa##..",
".#bbbb#bbaacc#aacaaaaaaaaaaaba#.",
"#ddbb#bbbbba#aaaaccaaaaaaaaaaaa#",
"#edddfgcbbbfaacaaaaccaaaaaaaaa#e",
".#hedddfhcfabaaccaaabccaaaaaa#e.",
"...##edddhaacbbaaccbaaaccaab#i..",
".....##e#baaaccabaaccbaabaa#i...",
"......##bacbaabccbaaaccabb#e....",
"......#bbbbccaabbccaaaaab#i.....",
".....#bbbbbbbccabbaccaab#i......",
".....#ebbbbbbbbccbaabba#i.......",
"......##ebbbbbbbbccaabhe........",
"........##ebbbbbbbbbb#e.........",
"..........##ibbbbbbbhe..........",
"............##ebbbb#e...........",
"..............#hee#i............",
"................##i............."};
END
my $bitmap = $mw->Pixmap(-data => $xpm);
$drawing->createImage(100, 100, -image => $bitmap);
MainLoop();
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.