471,073 Members | 1,392 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

FileHandles to string

Hi all,
I am having trouble opening a file and displaying its contents. I have
built into the code test strings and tried to display them, and all
have no output (i am assuming that is because they are all
null-pointers), and the code is part of a cgi.
Any help would be appreciated, the code is below, and the lines
commented out are the ones crashing!

open(File, "> /someWhere/My.txt") || die $errorString="can't
open";
@ThreadPairs = <File>;
foreach $items(@ThreadPairs){
($ThreadPosition,$ThreadName)=split(/=/,$items,2);
$fields{$ThreadPosition}=$ThreadName;
}
if($fields{Thread} == 2){ $tempTest="yes"}
$finalCount = "1" + $fields{Thread};
for($PosCount = 1; $PosCount < $finalCount; $PosCount++){
$tempThreadPos = "Thread"."$PosCount";
$tempThreadName = $fields{$tempThreadPos};
}
close(File);
}

thanks All
Andrew
Jul 19 '05 #1
1 3505
Andrew wrote:
Hi all,
I am having trouble opening a file and displaying its contents. I have
built into the code test strings and tried to display them, and all
have no output (i am assuming that is because they are all
null-pointers), and the code is part of a cgi.
Any help would be appreciated, the code is below, and the lines
commented out are the ones crashing!

open(File, "> /someWhere/My.txt") || die $errorString="can't
open";
You are opening the file for writing.
The more standard form would be
open(File, "> /someWhere/My.txt") or die "can't open file
/someWhere/My.txt for writing because $!\n";
@ThreadPairs = <File>;
And here you are trying to read from the file. Doesn't seem like a good idea
to me.
foreach $items(@ThreadPairs){


No "my"?
Then I guess you aren't using strictures and warnings, either? You should!

jue
Jul 19 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

16 posts views Thread by Krakatioison | last post: by
5 posts views Thread by Stu Cazzo | last post: by
9 posts views Thread by John F Dutcher | last post: by
9 posts views Thread by Derek Hart | last post: by
10 posts views Thread by Angus Leeming | last post: by
2 posts views Thread by Andrew | last post: by
2 posts views Thread by s | last post: by
3 posts views Thread by Sako | last post: by
reply views Thread by norseman | last post: by

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.