Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

installing modules

by emilford (Friar)
on Apr 13, 2002 at 20:27 UTC ( #158849=perlquestion: print w/ replies, xml ) Need Help??
emilford has asked for the wisdom of the Perl Monks concerning the following question:

I'm having trouble installing extra modules on an active state (windows) perl installation. I download the zip file containing the necessary files and excute the install command in the README file (ppm install xxxx.ppd) and it finishes with no errors. When I try to use the module, however, I get errors. The most recent error was with an MP3 module:
#!/usr/bin/perl -w use strict; use MP3::ID3v1Tag; opendir(DIR, "H:\\test") || die "Unable to open directory: $!"; my @file_names = readdir(DIR); closedir(DIR); my ($title, $artist, $mp3_file); foreach my $file (@file_names) { $mp3_file = new MP3::ID3v1Tag("$file"); $title = $mp3_file->get_title(); $artist = $mp3_file ->get_artist(); print "$title - artist\n"; } and I get this error...... Can't open .: Permission denied at d:/Perl/site/lib/MP3/ID3vTag.pl lin +e 83 Can't call method "get_title" on an undefined value at rename.pl line +57
Any suggestions?

Comment on installing modules
Download Code
Re: installing modules
by BUU (Prior) on Apr 13, 2002 at 20:29 UTC
    command->ppm;ppm->install mod_name;
Why Johnny can't troubleshoot.
by boo_radley (Parson) on Apr 13, 2002 at 21:02 UTC
    using psi::esp, I bet you're trying to get an id3 tag on a directory, maybe . or ..
    try changing
    my ($title, $artist, $mp3_file); foreach my $file (@file_names) { $mp3_file = new MP3::ID3v1Tag("$file"); $title = $mp3_file->get_title(); $artist = $mp3_file ->get_artist(); print "$title - artist\n"; }
    to
    my ($title, $artist, $mp3_file); foreach my $file (@file_names) { print "now working with file '$file'\n"; # remove mp3_file from the my declaration outside the loop my $mp3_file = new MP3::ID3v1Tag("$file"); die "Can't create id tag : $!" unless $mp3_file; $title = $mp3_file->get_title(); $artist = $mp3_file ->get_artist(); print "$title - artist\n"; }
    to get a more detailed error message. Also use -d to determine if $file is really a directory and take appropriate action.
Re: installing modules
by RMGir (Prior) on Apr 14, 2002 at 01:20 UTC
    Another problem that the others did not mention is that readdir will return file NAMES, not full paths.

    If you do:

    my $dir='h:\test'; opendir(DIR, $dir) || die "Unable to open directory: $!"; my @file_names = grep {-f $_} map "$dir\\$_",readdir(DIR); closedir(DIR);
    you'll wind up with a list in @file_names of the full paths of the files, and ONLY the files, in that directory.

    You could also add a grep on /mp3/i in that list to make sure you only get the mp3 files, since those are what you're looking for...
    --
    Mike

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://158849]
Approved by ehdonhon
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (8)
As of 2015-01-25 14:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My top resolution in 2015 is:

















    Results (183 votes), past polls