use strict; use utf8; $| = 1; ############################################################# # recursivSearchFreedb ############################################################# sub recursivSearchFreedb { my ($dir) = @_; die "dir $dir\n" if(!$dir || !(-e $dir && -d $dir)); $dir =~ s/[\/\\]+/\//og; $dir = $dir . '/' if( $dir !~ /\/$/o ); my ($dirname) = ( $dir =~ /^.*\/([^\/]+?)\/*$/o ); opendir(DIR,$dir) || warn __LINE__."$!\n"; my @all_dir_files = readdir(DIR); closedir(DIR); print "Folder: $dir => $dirname\n"; foreach my $dir_file ( sort @all_dir_files ) { $dir_file =~ /^\.+$/o && next; my $abspath = $dir . $dir_file; if( -d $abspath ) { recursivSearchFreedb($abspath); } else { if($dir_file =~ /(^COPYING$|^README$)/io) { print "skipping $dir_file\n"; next; } elsif(-z $abspath) { next; } my ($content); open(IN, "<$abspath") || die "$!\n"; while(my $line = ) { next if not $line =~ /^#\s+xmcd/o; $content .= $line; my ($TITLEALL,$DISCID,$GENRE); for(;;) { my $line2 = ; if($line2=~/^\s*DTITLE\s*=(.*)$/o) {$TITLEALL .= $1;} if($line2=~/^\s*DISCID=\s*(.+?)\s*$/o) {$DISCID = $1;} if($line2=~/^\s*DGENRE\s*=(.*)$/o) {$GENRE .= $1;} $content .= $line2; if($line2 =~ /^PLAYORDER=/o) { if( $TITLEALL =~ /Romanti[cqk]/io ) { print FILE "$content\n"; } last; } } } close(IN); } } } ############################################################ # main starts here ############################################################ open(FILE, ">C:/MyScripts/sresult_standalone.txt") || die "$!\n"; binmode FILE, ":utf8"; recursivSearchFreedb('C:/MyScripts/freedb-update-20200201-20200301'); close(FILE); print "End of script\n";