in reply to Globally change ucfirst in mod_perl

If you read the docs for ucfirst and \U, you'll notice that \U is implemented in terms of ucfirst. Can't use that, either. :-)

------
We are the carpenters and bricklayers of the Information Age.

Then there are Damian modules.... *sigh* ... that's not about being less-lazy -- that's about being on some really good drugs -- you know, there is no spoon. - flyingmoose

I shouldn't have to say this, but any code, unless otherwise stated, is untested

  • Comment on Re: Globally change ucfirst in mod_perl

Replies are listed 'Best First'.
Re: Re: Globally change ucfirst in mod_perl
by Roy Johnson (Monsignor) on May 20, 2004 at 13:58 UTC
    No, \u is ucfirst, \U is uc. Interestingly, either will work in redefining ucfirst. Perl knows that \u means Perl's own ucfirst, even if ucfirst has been redefined.
    BEGIN { *CORE::GLOBAL::ucfirst = sub { join ' ', map "\u$_", split / /, @_ ? $_[0] : $_; } } $_ = "one two 'three' four\n"; print "\u$_"; print ucfirst;
    And in fact, my original suggestion even works! Perl is way ahead of the DWIM curve.
    BEGIN { *CORE::GLOBAL::ucfirst = sub { join ' ', map ucfirst, split / /, @_ ? $_[0] : $_; } } $_ = "one two 'three' four\n"; print "\u$_"; print ucfirst;
    Update: fixed default-as-$_ code.

    The PerlMonk tr/// Advocate