develooper Front page | perl.beginners | Postings from May 2008

Re: how to shorten this code ? x occur how many times in variable

Thread Previous | Thread Next
From:
John W. Krahn
Date:
May 7, 2008 18:15
Subject:
Re: how to shorten this code ? x occur how many times in variable
Richard Lee wrote:
> Rob Dixon wrote:
>>  
>> returns the number of colons found but leaves them untouched. Similarly
>>
>>   $str =? tr/\t /_/;
> 
> this is great!!
> 
> use warnings;
> use strict;
> 
> my $str = 'ab:cd:ef:g:hi::now;';
> print $str =~ tr/:// . "\n";
> print $str =~ tr/:b/_X/ . "\n";
> 
> print "$str\n";
> 
> 
> ././././././testthis.pl
> 6
> 7
> aX_cd_ef_g_hi__now;
> 
> BTW, what is =?    ? or is that a typo?
> 
> $str =? tr/\t /_/;

Typo.


John
-- 
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order.                            -- Larry Wall

Thread Previous | Thread Next


Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About