Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Giving up on ucfirst.

by Kickstart (Pilgrim)
on Dec 15, 2001 at 04:24 UTC ( [id://132150]=note: print w/replies, xml ) Need Help??


in reply to Updated code...
in thread Making a title/headline

Here's is more updated code, definitely better, in that it actually works on the first word, now I need it to work in the loop.

sub make_a_title { my @nocapslist = ( 'in', 'and', 'the', 'for', 'it', 'but', 'to', 'with', 'about', 'or', 'nor', 'because', 'as', 'that' ); my @wordlist = split (/\s+/, $_[0]); $wordlist[0] =~ s/(\w+)/\u\L$1/g; print "@wordlist\n"; foreach $word (@wordlist) { unless (grep {$_ eq $word} @wordlist) { $word =~ s/(\w+)/\u\L$1/g; print $word; } return join(' ', @wordlist); } }

Kickstart

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (4)
As of 2024-04-19 04:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found