Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

File access

Posted on 1999-01-12
3
162 Views
Last Modified: 2010-08-05
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
Comment
Question by:georgep23
  • 2
3 Comments
 
LVL 51

Accepted Solution

by:
ahoffmann earned 50 total points
ID: 1207518
$theQuestion = <FP>;
chop $theQuestion ;
0
 
LVL 84

Expert Comment

by:ozo
ID: 1207519
chomp would be safer, only removing the record separator if it's there.
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 1207520
ozo is right
(I really should switch over to 5.00x instead of using 4.036 :)
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Existing perl code to be changed for ftp to sftp handling 14 212
instmodsh - listing perl modules 2 83
Perl Frameworks 1 97
Call Shell Script from Perl Script 6 133
Many time we need to work with multiple files all together. If its windows system then we can use some GUI based editor to accomplish our task. But what if you are on putty or have only CLI(Command Line Interface) as an option to  edit your files. I…
A year or so back I was asked to have a play with MongoDB; within half an hour I had downloaded (http://www.mongodb.org/downloads),  installed and started the daemon, and had a console window open. After an hour or two of playing at the command …
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question