Help for this page

Select Code to Download


  1. or download this
    print "Please enter your name:\n";
    chomp( $name = <> );
    $x = ucfirst $name;
    print $x;
    
  2. or download this
    # The \u metacharacter acts only upon the first character.
    # No need for substr.
    $x = "\u$name";
    
  3. or download this
    # Assuming Perl 5.14+
    $x = $name =~ s/^(.)/\u$1/r;
    
  4. or download this
    $x = $name;
    $x =~ s/^(.)/\u$1/;