473,547 Members | 2,553 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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*******@hotma il.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 3434
#!/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*******@hotma il.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*******@hotma il.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*******@hotma il.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
2186
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 minutes. It is enough of a difference that unless I can figure out what I did wrong or a better way of doing it I might not be able to use python...
1
1951
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 into a textarea box. Below this box there are two buttons ... one that is labelled "Save & Exit" and other that is labelled "Save and Preview" On...
3
6534
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 should run on a Unix box I have. Both scripts run ok, except for the part when Windows try's to call out the Unix script. I have it set up where the Unix...
1
4669
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 of which platform I use to access the directory.) Platform 1: perl is installed in /tps/bin/perl. CPAN modules are available Perl is also...
3
15273
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 have a perl script that runs on my webserver, which is supposed to login to the gameserver and download the log. The problem is that when it gets to...
3
4941
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 to use the 'Shell()'-command . This didn't work: Either I get an "File not found" error, or I get no error at all, but the PERL script isn't...
1
2513
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 met when running my scripts. Could somebody pay attention to look into the below details to give some help? Really appreciate!!!!! Let me...
2
1712
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 which would take in as input the state code, of the 50 states belonging to the Unites States of America. After the user enters the two letter code...
5
1766
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 correctly, it basically creates spreadsheets, but not opening an existing spreadsheet and then updating and saving it, which is what I want to do. Do you...
3
2328
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 the interpreter manually...look what it says: i've tried with /web/cgi-bin/php "$HOME/html/path/to/my/script.php as command and it doesn't...
0
7510
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7437
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7703
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7947
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
6032
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5362
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5081
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3473
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
748
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.