Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: Removing space at end of field and converting to text

by tangent (Deacon)
on Apr 13, 2012 at 10:48 UTC ( #964892=note: print w/ replies, xml ) Need Help??


in reply to Removing space at end of field and converting to text

Assuming you don't want any linebreaks or whitespace at the end of the field, why not just:

$field =~ s/\s+$//;
For linebreaks in the middle of the text, and coming from different machines, this works for me:
if ($field =~ m/\r/) { $field =~ s/\n//g; $field =~ s/\r/<br>/g; } elsif ($field =~ m/\n/) { $field =~ s/\n/<br>/g; }


Comment on Re: Removing space at end of field and converting to text
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://964892]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (10)
As of 2014-09-16 15:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (33 votes), past polls