develooper Front page | perl.perl6.language | Postings from January 2010

Counting characters

Thread Next
From:
Carl Mäsak
Date:
January 27, 2010 05:01
Subject:
Counting characters
Message ID:
16d769b71001270501o1a8b1364k67b18da2976dbee2@mail.gmail.com
How is "character counting" done in Perl 6?

In Perl 5, it is `scalar tr/CG//` if I want to count the number of Cs
plus the number of Gs in a string.

S05 describes tr/// in terms of the .trans function, a handsome but
very different beast. Specifically, it doesn't seem to have a "scalar
context", with which one could count things.

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About