Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
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":



  • 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.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (3)
As of 2024-04-25 23:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found