Solved

scalar question

Posted on 2000-02-15
3
211 Views
Last Modified: 2012-06-27
Hi there, I'm new to Perl.
How do I remove the last character of a scalar?
For example, I have
$temp = "1234\n";
I want to get rid of the '\n', is there a function, or a regular operation to do that?
Thanks much.
0
Comment
Question by:kitwei
3 Comments
 
LVL 16

Accepted Solution

by:
maneshr earned 20 total points
Comment Utility
try this.

$temp=chomp($temp);

OR

$temp=~ s/\n//g;

OR

$temp=chop($temp)
0
 
LVL 84

Expert Comment

by:ozo
Comment Utility
#You mean
chomp($temp);
#or
chop($temp);
0
 

Author Comment

by:kitwei
Comment Utility
chomp and chop don't need to be assigned to $temp again, else I get nothing, but they all work.
thanks
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

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…
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…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

772 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

11 Experts available now in Live!

Get 1:1 Help Now