Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • sub uc_prop { # inefficient
      my $t = reverse shift;
      my $h = uc chop $t;
      return $h . reverse $t;
    }

    (Of course you can do the same thing more efficiently – and boringly:)

    sub uc_prop {
      my $t = shift;
      my $h = uc substr $t, 0, 1, '';
      return $h . $t;
    }

    (The following one might be more efficient. Or it may not be.)

    sub uc_prop {
      my $s = shift;
      my $h = uc substr $s, 0, 1, '';
      substr $s, 0, 0, $h;
      return $s;
    }

    (The first one is cool though.)