Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

switch, transliteration ( tr/// ) of $_ issue

by whakka (Hermit)
on Nov 18, 2008 at 15:56 UTC ( #724306=perlquestion: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    switch ( $foo ) {
        case ( tr/I/I/ == 1 ) { $bar = 'low' }
    ...
        case ( tr/I/I/ == 3 ) { $bar = 'high' }
        else { warn "Bad $_\n" }
    }
    
  2. or download this
    Use of uninitialized value $_ in transliteration (tr///)
    
  3. or download this
    #!perl! -w
    use strict;
    ...
    }
    
    print "Foo: $foo Bar: $bar\n";
    
  4. or download this
    given ( $foo ) {
        when ( tr/I/I/ == 1 ) { $bar = 'low' }
    ...
        when ( tr/I/I/ == 3 ) { $bar = 'high' }
        default { $bar = "drat" }
    }
    

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://724306]
Approved by kyle
Front-paged by moritz
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (6)
As of 2018-07-17 09:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    It has been suggested to rename Perl 6 in order to boost its marketing potential. Which name would you prefer?















    Results (363 votes). Check out past polls.

    Notices?