In my ongoing quest to learn Perl::Tk, I've stumbled upon an error that has me stumped. First, the code:
use MP3::Info; ... sub getInfo { # entry is a single line from the .m3u # which is the path up to and including the # song file. my ($entry) = shift; if ($entry =~ /\.ogg$/i) { my $ogg = Ogg::Vorbis->new; open(IN, "< $entry"); $ogg->open(IN); my $oggInfo = $ogg->info; my %tag = %{$ogg->comment}; close(IN); foreach my $key (keys %tag) { if ($key =~ /^artist/) { $info{artist} = $tag{$key}; } elsif ($key =~ /^album/) { $info{album} = $tag{$key}; } elsif ($key =~ /^title/) { $info{song} = $tag{$key}; } elsif ($key =~ /^genre/) { $info{type} = $tag{$key}; } elsif ($key =~ /^date/) { $info{year} = $tag{$key}; } } } elsif ($entry =~ /\.mp3$/i) { my $mp3hashref = get_mp3tag ($entry); my %mp3tag = %$mp3hashref if ($mp3hashref); $info{artist} = $mp3tag{ARTIST}; $info{album} = $mp3tag{ALBUM}; $info{song} = $mp3tag{TITLE}; $info{type} = $mp3tag{GENRE}; $info{year} = $mp3tag{YEAR}; } }

The above subroutine basically extracts either MP3 or Ogg tags from song files and populates the $info hash (which in turn populates the UI.

For the most part, it works flawlessly. However, every so often it crashes with the following:

Tk::Error: Tk::Listbox=HASH(0x8646f6c) is not a Tk object at /usr/lib/ +perl5/site_perl/5.8.0/i386-linux-thread-multi/Tk.pm line 91. (command + bound to event)

The really odd part (to my mind) is that if I comment out the line

my %mp3tag = %$mp3hashref if ($mp3hashref);

the script runs just fine. Of course, the UI is never populated with anything, but it doesn't crash either.

If anyone has any suggestions, I'd really appreciate it. (The entire script is way too long to post here. If you want to view the entire script, the CVS is available at mcc.sourceforge.net or contact me and I'll be glad to email it to you.

Thanks!

If things get any worse, I'll have to ask you to stop helping me.


In reply to Tk::Listbox=HASH Error by shockme

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.