good chemistry is complicated, and a little bit messy -LW |
|
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
G'day mrras25, Firstly, there's two issues with how you generate $content. The individual strings have double-quotes which interpolate and will cause problems with embedded '$' or '@' characters: use single-quotes instead to avoid this. Any $content .= '...' line where the string starts with a digit will leave the start of that line indistinguishable from the value at the end of the previous line. Consider a situation where $content .= '3PA/Game 16.1 ...' follows $content .= '... Opp 3PM/Game 4.8': $content now contains '... Opp 3PM/Game 4.83PA/Game 16.1 ...'. A way around this is to get rid of every $content .= and just use a single join with a space: my $content = join ' ', '...', '...', '...';. Back to your question. This code will do what you want with the data you've shown here:
Here's a complete script with all your input showing full output: <Reveal this spoiler or all in this thread>
Update: I made a small change to the part of the regex matching a potential leading sign: s{[+-]*}{[+-]?} -- Ken In reply to Re: Words and Numbers to hash
by kcott
|
|