File Handling ! Why oh why can't I get it to find EOF

11-22-03, 11:44 AM
|
 |
Code Master
|
|
Join Date: Jun 2003
Location: North East England/UK
Posts: 874
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
|
File Handling ! Why oh why can't I get it to find EOF
I have a html page that looks to a file that contains a sentence of info. The page has worked for me when I put END at the end of this txt file but I found out I cant use this as Im appending to the file later on. Heres my script that worked...
open (POSTINFO,"<GeneralBoard.log");
while ($BoardDetails ne "END")
{
$BoardDetails=<POSTINFO>;
print $BoardDetails;
}
close (POSTINFO);
and the txt file format
DAL : Message board title : Date : Time
DAL1 : Message board Title : Date : Time
...
...
(...ect)
END
Ive had to replace it with this;
open (POSTINFO,"<GeneralBoard.log");
while (<>)
{
$BoardDetails=<POSTINFO>;
print $BoardDetails;
}continue{
close ARGV if eof;
}
close (POSTINFO);
and the txt file format
DAL : Message board title : Date : Time
DAL1 : Message board Title : Date : Time
...
...
(...ect)
----------------
But I keep getting either server errors or the information contained within the txt file doesnt show. Why cant it just read the file until there is nothing more to read. Ive never had a problem with this with any other language but perl obvously does things a little different than Im used to.
Ive tryied things like this;
open (POSTINFO,"<GeneralBoard.log");
while (POSTINFO ne eof)
open (POSTINFO,"<GeneralBoard.log");
while ($BoardDetails ne "")
open (POSTINFO,"<GeneralBoard.log");
while (!eof)
can anyone correct my code on the end of file peramaters.
Thanks
DAL
(ps does anyone have problems clicking on the smiles in the post new thread screen?...I keep getting errors with it) =S
MY LIFE IS FULL OF ERRORS! =(
__________________
"once upon a midnight dreary, while i pron surfed, weak and weary, over many a strange and spurious site of 'hot xxx galore'. While i clicked my fav'rite bookmark, suddenly there came a warning, and my heart was filled with mourning, mourning for my dear amour," 'Tis not possible!", i muttered, "give me back my free hardcore!" quoth the server, 404."
|

11-22-03, 12:15 PM
|
|
Coding Addict
|
|
Join Date: Oct 2003
Location: California
Posts: 359
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hi DAL,
Try this:
As long as you are trying to print the entire file, that will work. Check the perlopentut pod for more info.
~Charlie
|

11-22-03, 12:17 PM
|
 |
Wannabe Coder
|
|
Join Date: Nov 2003
Posts: 136
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
try like this:
open (POSTINFO,"<GeneralBoard.log");
while (<POSTINFO>)
{
$BoardDetails=<POSTINFO>;
print $BoardDetails;
}
close (POSTINFO);
you might also want to look into using Tie::File for working with text files
|

11-22-03, 01:47 PM
|
 |
Code Master
|
|
Join Date: Jun 2003
Location: North East England/UK
Posts: 874
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
|
Sorted!
__________________
"once upon a midnight dreary, while i pron surfed, weak and weary, over many a strange and spurious site of 'hot xxx galore'. While i clicked my fav'rite bookmark, suddenly there came a warning, and my heart was filled with mourning, mourning for my dear amour," 'Tis not possible!", i muttered, "give me back my free hardcore!" quoth the server, 404."
|

11-22-03, 01:50 PM
|
|
Coding Addict
|
|
Join Date: Oct 2003
Location: California
Posts: 359
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Quote:
|
Originally Posted by DAL
Sorted ! Cheers ppl =)
|
What did you end up doing to get it working? Just in case anyone else comes along with the same type of problem.
~Charlie
|

11-22-03, 02:21 PM
|
 |
Code Master
|
|
Join Date: Jun 2003
Location: North East England/UK
Posts: 874
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
open (POSTINFO,"<GeneralBoard.log");
while (<POSTINFO>)
{
$BoardDetails=<POSTINFO>;
print $BoardDetails
}
close (POSTINFO);
I didnt try the other way by adding the file name into a variable as this doesnt ever change so it can be staticaly addressed open ie["<GeneralBoard.log");]
Thanks again ppl
It apears I was dumber than I look!
=D
__________________
"once upon a midnight dreary, while i pron surfed, weak and weary, over many a strange and spurious site of 'hot xxx galore'. While i clicked my fav'rite bookmark, suddenly there came a warning, and my heart was filled with mourning, mourning for my dear amour," 'Tis not possible!", i muttered, "give me back my free hardcore!" quoth the server, 404."
|

11-22-03, 05:46 PM
|
|
Coding Addict
|
|
Join Date: Oct 2003
Location: California
Posts: 359
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Yeah, I was being a little too generic in my example. I was testing it on a local file and was too lazy to change the file name  Anyhow, glad you have it working.
~Charlie
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|