Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re^2: Alpha-search, by letter.

by Andrew_Levenson (Hermit)
on Mar 14, 2006 at 21:25 UTC ( [id://536708]=note: print w/replies, xml ) Need Help??


in reply to Re: Alpha-search, by letter.
in thread Alpha-search, by letter.

How does tr/// work, exactly? I can't find it in the perlops.
Thanks.

Replies are listed 'Best First'.
Re^3: Alpha-search, by letter.
by rafl (Friar) on Mar 14, 2006 at 21:34 UTC

    See

    tr/SEARCHLIST/REPLACEMENTLIST/cds
    y/SEARCHLIST/REPLACEMENTLIST/cds
    

    in perlop. It's around line 1100 in my version.

Re^3: Alpha-search, by letter.
by blogical (Pilgrim) on Mar 14, 2006 at 21:50 UTC
    Transliteration is what you're trying to do- map one set of characters onto another set. Specifically, you're trying to implement rot6, a transliteration cipher (not much of an encryption, btw).

    tr///, aka y///, uses the second set of characters to replace their counterparts from the first set.

    my $word = "abc"; $abc =~ tr/acb/llo/; print $word;
    yeilds: lol
Re^3: Alpha-search, by letter.
by QM (Parson) on Mar 14, 2006 at 21:50 UTC
    Use this link: tr///

    -QM
    --
    Quantum Mechanics: The dreams stuff is made of

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://536708]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (6)
As of 2024-04-23 10:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found