SPUG: reg pattern matching in a loop

Ingy dot Net ingy at ingy.net
Fri Oct 14 18:04:17 PDT 2011


Mmm, Golf...

use IO::All;io($OUTPUTFILE)->append($_)for map{tr/
/|/s;$_}io($PRODUCTLINE)->slurp

On Fri, Oct 14, 2011 at 8:47 PM, Devin Ben-Hur <dbenhur at whitepages.com>wrote:

> On 10/14/2011 04:01 PM, Noah Rømer wrote:
>
>> If you don't want
>> to condense multiple spaces into a single '|' ('    ' ->  '|'), but want
>> a '|' for each space char ('    ' ->  '||||'), then the 'tr' command is
>> your friend
>>
>> tr/ /|/;
>>
>> This will replace every space found with a pipe character.
>>
>
>
> Perl's transliterate will happily condense multiple substitutions to the
> same character. The squash option tells it to do so: tr/ /|/s;
>
> ______________________________**______________________________**_
> Seattle Perl Users Group Mailing List
>    POST TO: spug-list at pm.org
> SUBSCRIPTION: http://mail.pm.org/mailman/**listinfo/spug-list<http://mail.pm.org/mailman/listinfo/spug-list>
>   MEETINGS: 3rd Tuesdays
>   WEB PAGE: http://seattleperl.org/
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.pm.org/pipermail/spug-list/attachments/20111014/32a81b91/attachment.html>


More information about the spug-list mailing list