in reply to shortening substitutions
The first two can be dealt with using tr
tr/";//d;update: except of course that it can't: tr/// will perform all such transliterations, not merely the first. If indeed only the first such match found should undergo substition and not the rest, then you're not going to get any more compact than the original code.
If the last s/// is to remove tabs, then you can add \t to the left-hand side of the above tr///. In any event, for performance reasons you want to leave the s/^\s+// by itself.
If you are brave and insist on this approach, you could try folding the rest into:
update: oops, seriously lagged here, and as pointed out, the following doesn't perform according to spec. The tr/// stuff still holds, though.
s/(?: |[";])//but I don't think it's as readadble. You could even add the ^\s+ as another alternation, but it would not be as efficient.
- another intruder with the mooring in the heart of the Perl
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: shortening substitutions
by salva (Canon) on Jun 17, 2005 at 13:32 UTC |