in reply to Re: Re: Globally change ucfirst in mod_perl
in thread Globally change ucfirst in mod_perl

A couple of points:

  1. There's a slight bug as is shown in the code below:
    BEGIN { *CORE::GLOBAL::ucfirst = sub { join ' ', map CORE::ucfirst, split / /, defined $_[0] ? $_[0] : $ +_; } } $_ = "I shouldn't be printing this, but I am anyway."; my $var = undef; print ucfirst $var;

    Perhaps you should be checking for the number of parameters passed instead?

    BEGIN { *CORE::GLOBAL::ucfirst = sub { join ' ', map CORE::ucfirst, split / /, @_ ? $_[0] : $_; } }
  2. The reason I used split ' ' was because the OP used it. Perhaps it's the behavior he wanted. Maybe not? Either way, there are benefits in both approaches.

antirice    
The first rule of Perl club is - use Perl
The
ith rule of Perl club is - follow rule i - 1 for i > 1