• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

Need perl help-Fixed

Chaotic42

Lifer
Edit: Ok, I fixed it. If you're bored, try to figure out what was wrong. It was one character. 😀



Hey guys. I wrote a perl script quite a while ago that ripped/encoded music. I lost the working version, and now I have a partially working version. It asks for the number of tracks, the name of each track, rips, then encodes.

It's supposed to put the track number infront of the name, then add ".mp3". So "Stairway to Heaven" would become "03-Stairway to Heaven.mp3". For some reason, it just makes it "3".

Here's the code (formatting error fixed):

---


#! /usr/bin/perl

print "Enter number of tracks- ";
$tracks=<STDIN>;
chomp $tracks;
print "Enter device name of CD (scd0)- ";
$device=<STDIN>;
if ($device eq ""){
$device="scd0";
}
chomp $device;
for $counter (1 .. $tracks){
print "Enter name of track \#$counter- ";
$track[$counter]=<STDIN>;
chomp $track[$counter];
}
print "Preparing to rip and encode $tracks tracks from device \"/dev/$device\".";
print "Track listings are as follows-\n";
for $counter (1 .. $tracks){
if ($counter < 10){
$track[$counter]="0".$counter."-".$track[$counter];
}
else {
$track[$counter]="0".$counter."-".$track[$counter];
}
print "$track[$counter]\n";
}
for $counter (1 .. $tracks){
system ("cdda2wav -D=0,1,0 -x -t$counter+$counter");
$track[$counter]=$track[$counter]..".mp3";
system ("lame --alt-preset insane audio.wav $track[$counter]");
system ("rm audio.wav");
}
print "Done!";
--

If there is a way to format the post better, let me know. The tabs aren't showing up. Thanks in advance.
 
That doesn't even compile. this line

print "Preparing to rip and encode $tracks tracks from device \"/dev/$device\".$print "Track listings are as follows-\n";

is missing a quote mark.
Is that suppsoed to be two seperate prtint statements or what?
 
Originally posted by: notfred
That doesn't even compile. this line

print "Preparing to rip and encode $tracks tracks from device \"/dev/$device\".$print "Track listings are as follows-\n";

is missing a quote mark.
Is that suppsoed to be two seperate prtint statements or what?

I fixed the problem, but what you quoted was a mistake. It was my editor trying to be smart and inserting a "$" instead of displaying the rest of the line.

Thanks for the reply.
 
Back
Top