Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 167
  • Last Modified:

File access

really simple problem.

I have a text file that contains a line of text followed by a /n character.

I want to open this file, and store the line of text into a variable without the /n character

Example:

     open (FP, "<$questionFile");
      $theQuestion = ????
     close (FP);

how do I store the contents of the file (one line of text) into the variable $theQuestion above without the /n character being stored in the variable?

thanks!!!
0
georgep23
Asked:
georgep23
  • 2
1 Solution
 
ahoffmannCommented:
$theQuestion = <FP>;
chop $theQuestion ;
0
 
ozoCommented:
chomp would be safer, only removing the record separator if it's there.
0
 
ahoffmannCommented:
ozo is right
(I really should switch over to 5.00x instead of using 4.036 :)
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now