All pastes #2049516 Raw Edit

Mine

public text v1 · immutable
#2049516 ·published 2011-04-22 23:28 UTC
rendered paste body
gar0t0@buuh:~/perl$ cat descritor.pl
#!/usr/bin/perl
use warnings;
use strict;
use Cwd;
use MP3::Info;

## Variaveis
my $version = 1;
my $location = $ARGV[0];

## Inicio
print "Bem vindo ao MP3 Descritor - $version\n";
print "Vou tentar executar o programa em $location\n" if(defined($location));

#my $location;
#if (@ARGV){
#   $location = $ARGV[0];
#   print "Vou tentar achar arquvos em $location\n";
#}
#else{
#   $location = getcwd;
#   print "Vou tentar achar arquivos no diretorio atual ($location)\n";
#}

@mp3_list = find_mp3($location);
die "Cannot work without a valid list. Sorry\n" unless (@mp3_list);

foreach my $mp3_file(@mp3_list){
   my $mp3_tag = get_mp3tagg($mp3_file) or die "Cannot retrive tags from $mp3_file: $!\n";
   my %mp3_tagss = %{$mp3_tags};

   format STDOUT_TOP=
   Report about all lmp3 files found.
   Total files found: @<<<<<<<
      scalar(@mp3_list)

   .

   format STDOUT=
   File @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
   $mp3_file

       ARTIST    |      TITLE    |      ALBUM    |     GENRE    |     TRACK
   --------------+---------------+---------------+--------------+--------------
   @<<<<<<<<<<<<<<<<|@<<<<<<<<<<<<<<<|@<<<<<<<<<<<<<<<|@<<<<<<<<<<<<<<<|@||||
   $mp3_tags{ARTIST},$mp3_tags{TITLE},$mp3_tags{ALBUM},$mp3_tags{GENRE},$mp3_tags{TRACKNUM}

   .

   write;
}

## Rotina
sub find_mp3{
   my $location = shift;
   $location='/';
   warn "No location passed as argument\n" unless (defined($location));

   my @list = <$location*.mp3>;

   warn "No MP3 finles found\n" unless (@list);
   return @list;
}
gar0t0@buuh:~/perl$