Problems? Is your data what you think it is? | |
PerlMonks |
Re: how to remove a string from end of a lineby graff (Chancellor) |
on Oct 09, 2015 at 22:10 UTC ( [id://1144340]=note: print w/replies, xml ) | Need Help?? |
The information you provided isn't much to go on. I'm sure you have more than just the one example string to deal with, so the question is: in what ways are all the other strings similar and not similar to the one example you've given?
Any of the following might serve as the strategy that solves not only the one example you gave, but all the other cases:
The point is that the solution depends on what you know about the input data - and how consistent the input is and what kinds of consistency it has (or doesn't have) - as well as how the output should differ. I tend to do a lot of "defensive programming" whenever it comes to applying this sort of filter to text data - a lot of data diagnosis (where possible) before writing the code, and enough tests in the code to make sure that the filter does what it's supposed to do, and reports when the input doesn't meet the necessary expectations.
In Section
Seekers of Perl Wisdom
|
|