Current location: Hot Scripts Forums » Programming Languages » Perl » What have I done wrong now???


What have I done wrong now???

Reply
  #1 (permalink)  
Old 11-24-03, 09:06 AM
DAL's Avatar
DAL DAL is offline
Code Master
 
Join Date: Jun 2003
Location: North East England/UK
Posts: 874
Thanks: 0
Thanked 0 Times in 0 Posts
Question 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."
Reply With Quote
  #2 (permalink)  
Old 11-24-03, 12:42 PM
Millennium's Avatar
Millennium Millennium is offline
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.
Reply With Quote
  #3 (permalink)  
Old 11-24-03, 01:40 PM
DAL's Avatar
DAL DAL is offline
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."
Reply With Quote
  #4 (permalink)  
Old 11-24-03, 03:56 PM
Millennium's Avatar
Millennium Millennium is offline
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.
Reply With Quote
  #5 (permalink)  
Old 11-24-03, 06:26 PM
DAL's Avatar
DAL DAL is offline
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."
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
adding new line in .txt file spinicrus PHP 6 06-22-11 06:18 AM
what am i doing wrong?? metamorphosis The Lounge 1 08-20-03 05:37 PM
help me determine whats wrong Cmrdrv The Lounge 6 08-12-03 11:57 AM
something wrong with this code superman PHP 3 07-06-03 10:55 PM
[RESOLVED]Forum time is wrong by 5 hours jrobbio HotScripts Site Bug Reports 1 06-07-03 10:46 PM


All times are GMT -5. The time now is 04:46 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.