develooper Front page | perl.perl5.porters | Postings from April 2011

perlop fib

From:
Tom Christiansen
Date:
April 26, 2011 18:01
Subject:
perlop fib
Message ID:
24029.1303866070@chthon
Yet another addition that has rendered existing documentation untrue:

    tr/SEARCHLIST/REPLACEMENTLIST/cdsr
    y/SEARCHLIST/REPLACEMENTLIST/cdsr

        Transliterates all occurrences of the characters found in the
        search list with the corresponding character in the replacement
        list.  It returns the number of characters replaced or deleted.  If
        no string is specified via the =~ or !~ operator, the $_ string is
        transliterated.  (The string specified with =~ must be a scalar
        variable, an array element, a hash element, or an assignment to one
        of those, i.e., an lvalue.)

        If the "/r" (non-destructive) option is used then it will perform
        the replacement on a copy of the string and return the copy whether
        or not it was modified. The original string will always remain
        unchanged in this case. The copy will always be a plain string,
        even if the input is an object or a tied variable.

--tom



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