Re: How to do CDDB lookup via Win32 Perl?
I'm having the same problem as described in the following post. Did anyone ever find a solution to this? Read this post again: http://aspn.activestate.com/ASPN/Mail/Message/1312188 Download this file: http://www.freedb.org/software/cddbidgen.zip Run this Perl code: --- use strict; use warnings; use CDDB; my $cddbp = new CDDB( Host = 'freedb.freedb.org', # default Port = 8880,# default Login = 'win32user', # Debug = 1 ) or die $!; my $strTOC = getTOCinfo('G:'); # getTOCinfo('E:'); # getTOCinfo('1:0:0'); # getTOCinfo('2:0:0'); if ( $strTOC ) { my(@array,$cddbp_id,$total_seconds,@track_offsets,@discs); @array = split ' ', $strTOC; $cddbp_id = $array[2]; $total_seconds = $array[-1]; push @track_offsets, $array[$_] for ( 4 .. $#array-1 ); ## @track_offsets is not getting populated ??? ## my($cddbp_id, $total_seconds, @track_offsets) = ## (split ' ',$strTOC)[2,-1,4..-2]; @discs = $cddbp-get_discs($cddbp_id,\@track_offsets,$total_seconds); foreach my $disc (@discs) { ppDisc($cddbp,$disc); } } #=== sub ppDisc { #=== my($cddbp,$disc) = @_; my($genre,$cddbp_id,$title) = @$disc; my $disc_info = $cddbp-get_disc_details($genre,$cddbp_id); my @track_titles = @{$disc_info-{ttitles}}; print $title, \n, = x length($title), \n; printf(%02d - %s\n, $_, $track_titles[$_]) for ( 1 .. @track_titles-1 ); } # end sub #=== sub getTOCinfo { #=== my($device) = @_; my($buf,$result); unless ( $device =~ /\w:|\d:\d:\d/ ) { print STDERR 'Error: misformed drive letter or device'; return undef; } $buf = `cddbidgen.exe`; ($result) = ($buf =~ /^.*.*?$device.*?.*?(cddb query.*?)\s+?[A-Z]/s); if ( $result ) { $result =~ s/\n//; # ??? } else { print STDERR Error: could not produce cddb query string for [$device]; } return $result; } # end sub --- It successfully produced output for two test cds ( one of them being a CD-EXTRA disc ): Counting Crows / Hard Candy === 01 - American Girls 02 - Good Time 03 - If I Could Give All My Love -or- Richard Manuel Is Dead 04 - Goodnight L.A. 05 - Butterfly In Reverese 06 - Miami 07 - New Frontier 08 - Carriage 09 - Black And Blue 10 - Why Should You Come When I Call? 11 - Up All Night (Frankie Miller Goes To Hollywood) 12 - Holiday In Spain Counting Crows / Across A Wire - Live In NYC (From The Ten Spot)(CD 2) == 01 - Angels Of The Silences 02 - Rain King 03 - Sullivan Street 04 - Children In Bloom 05 - Have You Seen Me Lately? 06 - Raining In Baltimore 07 - Round Here 08 - I'm Not Sleeping 09 - A Murder Of One 10 - A Long December 11 - Walkaways Note that you can use a drive letter or a device name. You'll need to press any key to continue after cddbidgen.exe gets the TOC information. I tried using IPC::Open2 to read/write to the program but I couldn't get it to work. Anyone know how to read input from an external program then press a key to make it exit? The source code for cddbidgen.exe is available so I'd just as well comment out that line and recompile. I couldn't figure out why this was failing: my($cddbp_id, $total_seconds, @track_offsets) = (split ' ',$strTOC)[2,-1,4..-2]; @track_offsets is always empty. ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re: XML::LibXML
- Original Message - From: Gladstone Alexander [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Friday, August 09, 2002 10:51 PM Subject: XML::LibXML Can someone tell me how to set up my windows 2000 machine to use XML::LibXML in my perl scripts? What do I need and where can I get it? Thanks. If you're looking for XML::LibXML, there's a ppm for it at: http://theoryx5.uwinnipeg.ca/ppmpackages/ You'll need more than just that, but I don't know the details. Hth Cheers, Rob ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re: How to do CDDB lookup via Win32 Perl?
Ron Grabowski wrote: I couldn't figure out why this was failing: my($cddbp_id, $total_seconds, @track_offsets) = (split ' ',$strTOC)[2,-1,4..-2]; @track_offsets is always empty. If the left value is greater than the right value then it returns the empty array. Workaround: my @x = split / /, $strTOC; my ($ci, $ts, @to) = (@x)[2, -1, 4 .. ($#x-1)]; -- ,-/- __ _ _ $Bill Luebkert ICQ=162126130 (_/ / )// // DBE Collectibles Mailto:[EMAIL PROTECTED] / ) /-- o // // http://dbecoll.tripod.com/ (Free site for Perl) -/-' /___/__/_/_ Castle of Medieval Myth Magic http://www.todbe.com/ ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
trying to understand how regex works
Hi all, I guess it must be a simple problem, but it's a mystery to me. I got 30 fields all separated by pipes in some files with many many lines. Some of the fields need to be changed, but mostly I have to drop any line that has certain values in certain fields. So I start by skipping any field that has garbage in it: open FOUT, /some/path/outputfile.txt; open FILE /some/path/inputfile.txt; whileFILE{ p=N; next if (/.*?\|value_garbage1\|.*?/ || /.*?\|value_garbage2\|.*?/ || /.*?\|value_garbage3\|.*?/); #and then I continue with an if if(/(.*?)\|(.*?)\|30 times/){ $p=Y; do something to $1; #change field 1 do something to $3; #change filed 3 $fld1=$newfld1; $fld2=$2; $fld3=$newfld3; $fld4=$4;and so on } print FOUT $fld1|$fld2|...|$fld30|\n if ($p=Y); #print the whole thing to the new output } Well, it happens that some of the lines are completely out of whack and the regex simply stops there - it doesn't exit, no errors but goes into an infinite loop even though I don't know how exactly is this possible. My second if states clearly (or not so clearly) that if the line does not have 30 fields it should skip the block, it should NOT print anything at the handle and should get the next line. For whatever reason, the first time it encounters a line with less that 30 fields, it just loops without end. I tried to solve this by replacing the .*? in the references by the actual format of each field and suddenly it started working but now the regex is a hundred times slower and the only thing that speeds it up is to go back to the .*? that really goes fast as long as the regex is true. I mean if I have 30 fields all the time, the regex works OK and it goes very fast. Anybody cares to explain this to me? Thanks, Dan __ Do You Yahoo!? HotJobs - Search Thousands of New Jobs http://www.hotjobs.com ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re: trying to understand how regex works
Dan Jablonsky wrote: Hi all, I guess it must be a simple problem, but it's a mystery to me. I got 30 fields all separated by pipes in some files with many many lines. Some of the fields need to be changed, but mostly I have to drop any line that has certain values in certain fields. So I start by skipping any field that has garbage in it: open FOUT, /some/path/outputfile.txt; open FILE /some/path/inputfile.txt; whileFILE{ p=N; next if (/.*?\|value_garbage1\|.*?/ || /.*?\|value_garbage2\|.*?/ || /.*?\|value_garbage3\|.*?/); #and then I continue with an if if(/(.*?)\|(.*?)\|30 times/){ $p=Y; do something to $1; #change field 1 do something to $3; #change filed 3 $fld1=$newfld1; $fld2=$2; $fld3=$newfld3; $fld4=$4;and so on } print FOUT $fld1|$fld2|...|$fld30|\n if ($p=Y); #print the whole thing to the new output } Well, it happens that some of the lines are completely out of whack and the regex simply stops there - it doesn't exit, no errors but goes into an infinite loop even though I don't know how exactly is this possible. My second if states clearly (or not so clearly) that if the line does not have 30 fields it should skip the block, it should NOT print anything at the handle and should get the next line. For whatever reason, the first time it encounters a line with less that 30 fields, it just loops without end. I tried to solve this by replacing the .*? in the references by the actual format of each field and suddenly it started working but now the regex is a hundred times slower and the only thing that speeds it up is to go back to the .*? that really goes fast as long as the regex is true. I mean if I have 30 fields all the time, the regex works OK and it goes very fast. Anybody cares to explain this to me? No, but I'll offer an alternative. while FILE { p = N; my @f = split /\s*\|\s*/, $_; if (@f != 30) { print Field count is , scalar @f, should be 30\n; # error processing ... } if ($f[1] =~ / ... ... -- ,-/- __ _ _ $Bill Luebkert ICQ=162126130 (_/ / )// // DBE Collectibles Mailto:[EMAIL PROTECTED] / ) /-- o // // http://dbecoll.tripod.com/ (Free site for Perl) -/-' /___/__/_/_ Castle of Medieval Myth Magic http://www.todbe.com/ ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re: trying to understand how regex works
open FOUT, /some/path/outputfile.txt; open FILE /some/path/inputfile.txt; open(FOUT, /some/path/outputfile.txt) or die(Error: $!); open(FILE /some/path/inputfile.txt) or die(Error: $!); whileFILE{ p=N; next if (/.*?\|value_garbage1\|.*?/ || /.*?\|value_garbage2\|.*?/ || /.*?\|value_garbage3\|.*?/); my $regex = join '|', 'value_garbage1', 'value_garbage2', 'value_garbage3'; next if /$regex/; if(/(.*?)\|(.*?)\|30 times/){ $p=Y; do something to $1; #change field 1 do something to $3; #change filed 3 $fld1=$newfld1; $fld2=$2; $fld3=$newfld3; $fld4=$4;and so on } print FOUT $fld1|$fld2|...|$fld30|\n if ($p=Y); If you put the print inside of the if(), you don't need $p. Look into the join() function: print FOUT join '|', $fld1, $fld2, $fld3; print FOUT join '|', @array; ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs