What have I done wrong now???

11-24-03, 09:06 AM
|
 |
Code Master
|
|
Join Date: Jun 2003
Location: North East England/UK
Posts: 874
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
What have I done wrong now???
(Ive repeated this thread as I think ppl where missing it in the last board)
(Forgive me if you have already seen it and Im now getting on ur wick! :s )
Another problem
I want to search through a pl file (HTML file really) and find the eof. Then I want to take so-many bytes backward to a place in that file for append.
Header info perl & <HTML>. This part of the file puts out the graphic for the board and sets up the tables ready.
Middle Each new entry is based on
<tr>
format for board. Message information ,pic,number of posts ect
</tr>
This is duplicated for each new message...
<tr>
format for board. Message information ,pic,number of posts ect
</tr>
Footer finishes the </table> and puts the graphic and form at the bottom of the page.
Since Footer is always a static lenght I want to find the start of footer for append for the new message;
<tr>
format for board. Message information ,pic,number of posts ect
</tr>
--------------------------
Syswrite statment clames in many resources that it can contain a negitive number!
"An OFFSET may be specified to write the data from some part of the string other than the beginning. A negative OFFSET specifies writing that many bytes counting backwards from the end of the string. In the case the SCALAR is empty you can use OFFSET but only zero offset. "
when I try;
open (ADDTHEPOST, ">>/homepages/39/d87399782/htdocs/Internal/Boardsys/general/GEN300001.pl") or die "Unable to write open file. Reason: $!";
syswrite ADDTHEPOST, "HELLO",-105,2;
close (ADDTHEPOST);
I get a server error of the following;
Software error:
Negative length at /homepages/39/d87399782/htdocs/Internal/Boardsys/general/Addpost.pl line 85.
?Whats up..
syswrite FILEHANDLE,SCALAR,LENGTH,OFFSET
syswrite ADDTHEPOST,"HELLO",-105,2
I am using offset 2 to find the end of file. What have I done wrong this time?
Thanks
DAL
------------------------------
__________________
"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-24-03, 12:42 PM
|
 |
Wannabe Coder
|
|
Join Date: Nov 2003
Posts: 136
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
delete it from the other thread so things don't get confusing.
|

11-24-03, 01:40 PM
|
 |
Code Master
|
|
Join Date: Jun 2003
Location: North East England/UK
Posts: 874
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Cant delete - is says I only can delete 60 min after creating - its past that now
Anyone got any clue how to seek through the file? I dont need to put it in a scalar as the thing is already stored in a file! Never had a problem with this in the past with other programming/scripting langauges. why the sudden change???
__________________
"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-24-03, 03:56 PM
|
 |
Wannabe Coder
|
|
Join Date: Nov 2003
Posts: 136
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
OK. I didn't realize that you can't delete the post.
I think you have LENGTH and OFFSET confused. OFFSET is the value to use to write from the end of the file (or the beginning). You can't write a file that is -105 bytes long, at least I don't think you can.
But I am not sure how using the file option ">>" (apppend mode) will affect using an offset, if at all.
|

11-24-03, 06:26 PM
|
 |
Code Master
|
|
Join Date: Jun 2003
Location: North East England/UK
Posts: 874
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Never mind I figured it out another way anyhow. by use of reading the file into an array
Ie;
open(INF,"/homepages/39/d87399782/htdocs$thefile") or dienice("Can't open survey.out: $!");
@ary = <INF>;
close(INF);
@Tophtml = @ary[0..$EndBlock];
@Bottomhtml = @ary[$EndBlock..$Total-2];
$AbsoluteBottom = "EOF\n";
And then I put in the code that i was wanting to append to, in the file.
Then I wrote the whole file again replacing the original content - It works gr8
chomp($thefile);
open (NEWMESSAGE, ">/homepages/39/d87399782/htdocs$thefile") or die "Unable to write open file. Reason: $!";
print NEWMESSAGE "@Tophtml";
print NEWMESSAGE "$html";
print NEWMESSAGE "@Bottomhtml";
print NEWMESSAGE "$AbsoluteBottom";
close (NEWMESSAGE);
__________________
"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."
|
|
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
|
|
|
|