CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate:
OK Writing CD Burner Script... output weird

 



JordanTLClive
Deleted

Oct 18, 2000, 9:41 PM

Post #1 of 5 (347 views)
OK Writing CD Burner Script... output weird Can't Post

I am writing a script that generates a filelist for a cd burner program. I will be allowing people to choose files to be burned to a cd and the filelist will be generated automatically so i can just download the file and burn. This is what I have so far:
<BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">code:</font><HR>


#! /usr/bin/perl
push(@INC, "/cgi-bin/burner");
require("CGI-LIB.PL");

#########
# CD-R List Creator
# This program takes the name of a file from a database to burn it
#########

# This is the path to where datafiles will be kept
$path = "/home/tlclive/tlclive-www/cgi-bin/burner/data";

# This is the extension of the file to create
$ext = ".mpj";

&ReadParse(*input);

open (FILE,">$path$input{'name'}$ext");
foreach (defined($input{'song'})){
print FILE "$input{'song'}\nc:\\mp3\\$song.mp3\n";
}


print "Content-type: text/html\n\n";
print "<HTML><head><title> Thanks! </title></head><body>";
print qq~
Thank you for ordering a CD! You will now be directed to a page to pay for it.
~;
print "</body>";
</pre><HR></BLOCKQUOTE>
I will be adding the order code after the important part (generating the playlist file) is finished. The script runs fine, creates the file and all, but the output is very strange.
First all the song titles show up on one line. Then it goes to the next line and outputs the c:mp3$input{'song'}.mp3. I need the output to be in this format:
Song Title
Location on my hard drive
Second Song Title
Location on my hard drive

The form is at http://www.tlclive.com/order.html. Can someone suggest changes that need to be made? Thanks
Jordan


dws
Deleted

Oct 19, 2000, 10:13 AM

Post #2 of 5 (347 views)
Re: OK Writing CD Burner Script... output weird [In reply to] Can't Post

Ponder the line
<BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">quote:</font><HR>foreach (defined($input{'song'})){<HR></BLOCKQUOTE>
and ask:
<OL TYPE=1>
<LI> What values does $input{'song'} hold?
<LI> What value does defined($input{'song'}) return?
<LI> How many trips through the foreach loop do you get given (2)?
</OL>


JordanTLClive
Deleted

Oct 19, 2000, 10:37 AM

Post #3 of 5 (347 views)
Re: OK Writing CD Burner Script... output weird [In reply to] Can't Post

LOL I realized that the way I had written it simply would not work so I changed a fwe things around. Now I'm using a multiple select list which ReadParse works with. Now I have the trouble of I simply do not know what to do to output the information! This is the code now:

<BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">code:</font><HR>


#! /usr/bin/perl
push(@INC, "/cgi-bin/burner");
require("CGI-LIB.PL");

#########
# CD-R List Creator
# This program takes the name of a file from a database to burn it
#########

# This is the path to where datafiles will be kept
$path = "/home/tlclive/tlclive-www/cgi-bin/burner/data";

# This is the extension of the file to create
$ext = ".mpj";

&ReadParse(*input);
@songs = split(/\0/,$input{'song'});

open (FILE,">$path$input{'name'}$ext");
foreach (@songs){
print FILE $song;
print FILE "\nc:\\mp3\\";
print FILE $song;
print FILE ".mp3\n";
}


print "Content-type: text/html\n\n";
print "<HTML><head><title> Thanks! </title></head><body>";
print qq~
Thank you for ordering a CD! You will now be directed to a page to pay for it.
~;
print "</body>";
</pre><HR></BLOCKQUOTE>

I dont really have experience outputting information in arrays, and this doesnt work. Am I closer? LOL


JordanTLClive
Deleted

Oct 19, 2000, 10:44 AM

Post #4 of 5 (347 views)
Re: OK Writing CD Burner Script... output weird [In reply to] Can't Post

I DID IT! LOL. OK so if you didnt notice this is the first time I've written a script from scratch so Im quite excited. This is the working code.....
<BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">code:</font><HR>


#! /usr/bin/perl
push(@INC, "/cgi-bin/burner");
require("CGI-LIB.PL");

#########
# CD-R List Creator
# This program takes the name of a file from a database to burn it
#########

# This is the path to where datafiles will be kept
$path = "/home/tlclive/tlclive-www/cgi-bin/burner/data";

# This is the extension of the file to create
$ext = ".mpj";

&ReadParse(*input);
@songs = split(/\0/,$input{'song'});

open (FILE,">$path$input{'name'}$ext");
foreach $i (0 .. $#songs){
print FILE $songs[$i];
print FILE "\nc:\\mp3\\";
print FILE $songs[$i];
print FILE ".mp3\n";
}


print "Content-type: text/html\n\n";
print "<HTML><head><title> Thanks! </title></head><body>";
print qq~
Thank you for ordering a CD! You will now be directed to a page to pay for it.
~;
print "</body>";
</pre><HR></BLOCKQUOTE>

Now I have to fancy it up (it will create a form for a payment processing script) and make the html a bit nicer. The one thing I still would like to fix is if a file with that name exists, to ask the user to rename it....


JordanTLClive
Deleted

Oct 19, 2000, 10:54 AM

Post #5 of 5 (347 views)
Re: OK Writing CD Burner Script... output weird [In reply to] Can't Post

Got that done, if filename exists, it asks for another filename Smile

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives