472,958 Members | 2,427 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,958 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 3555
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

16
by: Krakatioison | last post by:
My sites navigation is like this: http://www.newsbackup.com/index.php?n=000000000040900000 , depending on the variable "n" (which is always a number), it will take me anywhere on the site......
5
by: Stu Cazzo | last post by:
I have the following: String myStringArray; String myString = "98 99 100"; I want to split up myString and put it into myStringArray. If I use this: myStringArray = myString.split(" "); it...
9
by: John F Dutcher | last post by:
I use code like the following to retrieve fields from a form: recd = recd.append(string.ljust(form.getfirst("lname",' '),15)) recd.append(string.ljust(form.getfirst("fname",' '),15)) etc.,...
9
by: Derek Hart | last post by:
I wish to execute code from a string. The string will have a function name, which will return a string: Dim a as string a = "MyFunctionName(param1, param2)" I have seen a ton of people...
10
by: Angus Leeming | last post by:
Hello, Could someone explain to me why the Standard conveners chose to typedef std::string rather than derive it from std::basic_string<char, ...>? The result of course is that it is...
37
by: Kevin C | last post by:
Quick Question: StringBuilder is obviously more efficient dealing with string concatenations than the old '+=' method... however, in dealing with relatively large string concatenations (ie,...
2
by: Andrew | last post by:
I have written two classes : a String Class based on the book " C++ in 21 days " and a GenericIpClass listed below : file GenericStringClass.h // Generic String class
2
by: s | last post by:
I'm getting compile errors on the following code: <code> #include <iostream> #include <fstream> #include <list> #include <string> using namespace std;
3
by: Sako | last post by:
I am trying to teach myself perl by writing a program I've been meaning to implement, so I am pretty green in perl. I'm having problems sharing filehandles opened by a thread - been RTFM for a few...
0
by: norseman | last post by:
Daniel de Sousa Barros wrote: ================================================ Click Start/settings/control panel/system/advanced/settings(in \ performance area)/advanced/change set System...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
2
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

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.