Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

delete the last \n and \r from s string

Status
Not open for further replies.

jimberger

Programmer
Joined
Jul 5, 2001
Messages
222
Location
GB
hi,

I have a string which contains \n in but i want to delete all the \n after the last word...i have tried

$message =~ s/\n*$//g;

but this dosen't work...any suggestions?
cheers
 
Try chomp $message.

Perl in a Nutshell said:
chomp

chomp $var
chomp @list

Removes any line-ending characters of a string in $var, or each string in @list, that correspond to the current value of $/ (not just any last character, as chop does). chomp returns the number of characters deleted. If $/ is empty (in paragraph mode), chomp removes all newlines from the selected string (or strings, if chomping a list). If no argument is given, the function chomps the $_ variable.
- Rieekan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top