Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re^3: Syntax Perl Version support $c = () = $a =~ /\./g

by mr_mischief (Monsignor)
on Jul 17, 2018 at 23:12 UTC ( #1218703=note: print w/replies, xml ) Need Help??


in reply to Re^2: Syntax Perl Version support $c = () = $a =~ /\./g
in thread Syntax Perl Version support $c = () = $a =~ /\./g

tr/// (sometimes spelled y///, especially in code golf) works on characters specifically. m// (sometimes spelled //) works on regular expression matches, which may concern one or more characters (or in special cases zero, such as split //, $foo;).

Perl takes text very seriously. There is a load to know about processing text in Perl, but the basics are pretty quick to grasp. The full story is not complete without at least these manual pages, although for this specific topic the first few should suffice.:

You might hope you never need to read perlebcdic, but there's that too.

Replies are listed 'Best First'.
Re^4: Syntax Perl Version support $c = () = $a =~ /\./g
by morgon (Priest) on Jul 18, 2018 at 00:09 UTC
    tr/// (sometimes spelled y///
    Hm, I have been using perl for something like 20 years and even though I have never (as far as I can remember) used tr at all I always knew it existed and what it does.

    "tr" must be short for "translate", but today I learn there is even another version of it - you can trade "tr" for "y" - well who would have guessed.

    As I am (a bit) interested in perl-arcana:

    Does anyone know where this "y" comes from?

    Is is a reference to another language who's users larry wanted to feel at home? Can anyone please enlighten me?

    Many thanks!

      > Is is a reference to another language who's users larry wanted to feel at home?

      Exactly. y/// comes from sed.

      ($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (4)
As of 2020-10-01 01:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    If at first I donít succeed, I Ö










    Results (172 votes). Check out past polls.

    Notices?