Syntactic Confectionery Delight | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
Welcome to the Monastery!
If you want to do it in one statement, you can do this:
You asked for a one-line solution. That will do it. A better solution (still using s///) is two lines, since alternation is expensive if you value time efficiency. I feel somewhat guilty for having retyped an answer that has been provided right at our fingertips in the Q&A section under the heading, How do I remove whitespace at the beginning or end of my string?. If you look there you'll see a lot of different alternatives of which one is sure to be right for any occasion. ;) This being your first post I just want to encourage you to familiarize yourself with the more helpful aspects of the Monastery such as the Q&A section, and the Tutorials section. The Q&A section is a FAQ of sorts; not a place to post questions, but rather, a place to post answers to common questions. You'll find a wealth of information there, most good, some just ok, but all there for edification. It also is a great idea to become familiar with the perldocs. If you have Perl, you have the perldocs. If you prefer reading them online, you can find them right here in the Monastery as well. Enjoy! Oh, this isn't related to your question, but rather, to the presentation of your question. I wanted to mention that you don't need to use <br> tags to create new lines within <code></ code> tags. Take a look at how your original post looks and you'll see what I mean. You did preview right? Dave "If I had my life to do over again, I'd be a plumber." -- Albert Einstein In reply to Re: remove both leading and trailing spaces
by davido
|
|