Solved

File access

Posted on 1999-01-12
3
157 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

I've just discovered very important differences between Windows an Unix formats in Perl,at least 5.xx.. MOST IMPORTANT: Use Unix file format while saving Your script. otherwise it will have ^M s or smth likely weird in the EOL, Then DO NOT use m…
In the distant past (last year) I hacked together a little toy that would allow a couple of Manager types to query, preview, and extract data from a number of MongoDB instances, to their tool of choice: Excel (http://dilbert.com/strips/comic/2007-08…
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…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

914 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now