473,378 Members | 1,417 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Help with a perl script?

Here's what I'm working with so far, but all I wind up with is a 0 byte
file at the end, and the error;

"Filehandle PLIST opened only for output at ./medialist.pl line 20."

I know this error is pretty self explanatory, but for some reason I'm
unable to correct it, and I was under the impression that I was opening /
creating my file in the correct manner. Can someone take a look at my
code below and point me in the right direction?

TIA,

- dkw
#!/usr/bin/perl -w
#
# The purpose is to create one "master playlist" of my mp3 collection
# on my Gnome desktop, by cat'ing the auto-generated playlists created
# when I rip and encode my cd collection into said "master playlist"
# and then add the correct path to the final playlist, then cleanup after
# myself.
#
# So far this script doesn't exactly work as planned.
#
# David K. Worman
# ac*******@hotmail.com
########################

$PLIST = "/home/dkworman/.gnome-desktop/playlist.m3u";
$FLIST = "/home/dkworman/.gnome-desktop/filelist.m3u";
system("rm $PLIST");
system("cat /misc/media/*.m3u > $FLIST");
open(PLIST, ">$PLIST") || die "Can't open $PLIST: $!n";
while (<PLIST>) {
open(FLIST) || die "Can't open $FLIST: $!n";
while (<FLIST>) {
chomp;
($song = $_);
$path = "/misc/media/";
print PLIST "$path$song";
}
close(FLIST);
}
close(PLIST);
system("rm $FLIST");
die();

Jul 19 '05 #1
3 3427
#!/usr/bin/perl -w
#
# The purpose is to create one "master playlist" of my mp3 collection
# on my Gnome desktop, by cat'ing the auto-generated playlists created
# when I rip and encode my cd collection into said "master playlist"
# and then add the correct path to the final playlist, then cleanup after
# myself.
#
# So far this script doesn't exactly work as planned.
#
# David K. Worman
# ac*******@hotmail.com
########################

$PLIST = "/home/dkworman/.gnome-desktop/playlist.m3u";
$FLIST = "/home/dkworman/.gnome-desktop/filelist.m3u";
system("rm $PLIST");
system("cat /misc/media/*.m3u > $FLIST");
open(PLIST, ">$PLIST") || die "Can't open $PLIST: $!n";
while (<PLIST>) {
open(FLIST) || die "Can't open $FLIST: $!n";
while (<FLIST>) {
chomp;
($song = $_);
$path = "/misc/media/";
print PLIST "$path$song";
}
close(FLIST);
}
close(PLIST);
system("rm $FLIST");
die();
Jul 19 '05 #2
David K. Worman wrote:
Here's what I'm working with so far, but all I wind up with is a 0 byte
file at the end, and the error;

"Filehandle PLIST opened only for output at ./medialist.pl line 20."

I know this error is pretty self explanatory, but for some reason I'm
unable to correct it, and I was under the impression that I was opening /
creating my file in the correct manner. Can someone take a look at my
code below and point me in the right direction?

TIA,

- dkw
#!/usr/bin/perl -w
#
# The purpose is to create one "master playlist" of my mp3 collection
# on my Gnome desktop, by cat'ing the auto-generated playlists created
# when I rip and encode my cd collection into said "master playlist"
# and then add the correct path to the final playlist, then cleanup after
# myself.
you mean cat *.m3u >> masterlist.m3u ?
#
# So far this script doesn't exactly work as planned.
#
# David K. Worman
# ac*******@hotmail.com
########################

add use strict; here.

$PLIST = "/home/dkworman/.gnome-desktop/playlist.m3u";
$FLIST = "/home/dkworman/.gnome-desktop/filelist.m3u";
system("rm $PLIST");
system("cat /misc/media/*.m3u > $FLIST");
This does probably not do what you want.
open(PLIST, ">$PLIST") || die "Can't open $PLIST: $!n";
you open for *writing*
while (<PLIST>) {
And start to read
open(FLIST) || die "Can't open $FLIST: $!n";
while (<FLIST>) {
chomp;
($song = $_);
why don't you read in $song in the while? You make the code unreadable
this way
$path = "/misc/media/";
this is a constant, lift it out of the while.
print PLIST "$path$song";
}
close(FLIST);
}
close(PLIST);
system("rm $FLIST");
read about "unlink"
die();

--
Kind regards, virtual home: http://johnbokma.com/ ICQ: 218175426
web site hints: http://johnbokma.com/websitedesign/
John I count my toes ~ one to ten ~ I meditate ~ and feel the Zen
Jul 19 '05 #3
On Mon, 22 Sep 2003 08:46:18 +0200, John Bokma wrote:
David K. Worman wrote:
Here's what I'm working with so far, but all I wind up with is a 0 byte
file at the end, and the error;

"Filehandle PLIST opened only for output at ./medialist.pl line 20."

I know this error is pretty self explanatory, but for some reason I'm
unable to correct it, and I was under the impression that I was opening
/ creating my file in the correct manner. Can someone take a look at my
code below and point me in the right direction?

TIA,

- dkw
#!/usr/bin/perl -w
#
# The purpose is to create one "master playlist" of my mp3 collection #
on my Gnome desktop, by cat'ing the auto-generated playlists created #
when I rip and encode my cd collection into said "master playlist" # and
then add the correct path to the final playlist, then cleanup after #
myself.


you mean cat *.m3u >> masterlist.m3u ?
#
# So far this script doesn't exactly work as planned. #
# David K. Worman
# ac*******@hotmail.com
########################

add use strict; here.

$PLIST = "/home/dkworman/.gnome-desktop/playlist.m3u"; $FLIST =
"/home/dkworman/.gnome-desktop/filelist.m3u"; system("rm $PLIST");
system("cat /misc/media/*.m3u > $FLIST");


This does probably not do what you want.
open(PLIST, ">$PLIST") || die "Can't open $PLIST: $!n";


you open for *writing*
while (<PLIST>) {


And start to read
open(FLIST) || die "Can't open $FLIST: $!n"; while (<FLIST>) {
chomp;
($song = $_);


why don't you read in $song in the while? You make the code unreadable
this way
$path = "/misc/media/";


this is a constant, lift it out of the while.
print PLIST "$path$song";
}
close(FLIST);
}
close(PLIST);
system("rm $FLIST");


read about "unlink"
die();


Code pasted all weird... it was (still is in my .pl) structured properly.
I'm just going to work with it more before coming back for help again.

- dkw
Jul 19 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Dennis Roberts | last post by:
I have a script to parse a dns querylog and generate some statistics. For a 750MB file a perl script using the same methods (splits) can parse the file in 3 minutes. My python script takes 25...
1
by: Robert V | last post by:
Hi all, I could use some help programming on of my Perl script to handle different submit buttons within the same form. Here is what I have so far. A user goes to a Web form and inputs some data...
3
by: dpackwood | last post by:
Hello, I have two different scripts that do pretty much the same thing. The main perl script is on Windows. It runs and in the middle of it, it then calls out another perl script that then...
1
by: Julia Bell | last post by:
I would like to run the same script on two different platforms. The directory in which the script(s) will be stored is common to the two platforms. (I see the same directory contents regardless...
3
by: FLOTServer | last post by:
Here's my problem: I run a gameserver that runs the game "Medal of Honor". On the game server is log file which contains all of the data from the players for that day (kills, deaths, etc...). I...
3
by: PzYon | last post by:
Hey 2gether! I'm trying to execute a PERL script on the web server when the user presses a button in an ASP.NET Web Application using Visual Basic. The most obvious solution for me seemed to be...
1
by: roadbai | last post by:
Hi all, This is the first time to post question here, hopefully experts of perl here can give me a hand, to be honest, I am kind of new to perl, and I am struggling with the "Out of memory" issue I...
2
by: MK | last post by:
Hello, I am new to XML and PERL and I have a few questions the answers to which I need to complete a project. All your time and effort would be highly appreciated. I have to make a small HTML page...
5
by: Louis | last post by:
I am trying to use php to update a spreadsheet (MS Excel or OpenOffice Calc) with data from MySQL. I looked into PEAR::Spreadsheet_Excel_Writer if it will do the job. If I understand it...
3
by: uzzi | last post by:
I don't know how to make a php script to work via cron...I want to make it run daily...My server API is CGI/Fast CGI.I have hosting from godaddy and in the help section i found that i have to specify...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.