Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: Re: Capitalize the 1st letter of each word

by mcogan1966 (Monk)
on Jan 15, 2004 at 20:02 UTC ( [id://321654]=note: print w/replies, xml ) Need Help??


in reply to Re: Capitalize the 1st letter of each word
in thread Capitalize the 1st letter of each word

Or even faster:
foreach (@array) { ucfirst($_); }
In this case, $_ will point to the actual element in the array.

Replies are listed 'Best First'.
Re: Re: Re: Capitalize the 1st letter of each word
by BrowserUk (Patriarch) on Jan 15, 2004 at 20:29 UTC

    Unfortunately, that doesn't work

    my @words = qw[ the quick brown fox ]; foreach (@words) { ucfirst($_); }; Useless use of ucfirst in void context at ...

    It would have to be

    foreach (@words) { $_ = ucfirst($_); }

    Or, more simple

    $_ = ucfirst for @words; print for @words; The Quick Brown Fox

    Examine what is said, not who speaks.
    "Efficiency is intelligent laziness." -David Dunham
    "Think for yourself!" - Abigail
    Timing (and a little luck) are everything!

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://321654]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (7)
As of 2024-04-23 16:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found