Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: Seeking a better way to do it

by vinoth.ree (Monsignor)
on Feb 01, 2013 at 05:15 UTC ( #1016438=note: print w/replies, xml ) Need Help??


in reply to Seeking a better way to do it

Use grep!!!

my $char_list = "Enter Iago, Othello, and others"; my @Word_List = grep { /[A-Z]\w+/ } split(/\W/, $char_list); print "@Word_List\n";
Update:

Simple way with regular expression,

my $char_list = "Enter Iago, Othello, and others"; my @Word_List; @Word_List = ($char_list =~ /([A-Z]\w+)/g); print "@Word_List\n";

Replies are listed 'Best First'.
Re^2: Seeking a better way to do it
by Tux (Abbot) on Feb 01, 2013 at 07:33 UTC

    That would also match camelCase and Some_shell, you'd want

    my @wordlist = ($string =~ m{\b ([A-Z][a-z]+) \b}gx);

    as BrowserUK also posted


    Enjoy, Have FUN! H.Merijn
Re^2: Seeking a better way to do it
by frozenwithjoy (Priest) on Feb 01, 2013 at 05:22 UTC
    This works assuming OP also wants to return 'Enter'. This is left out of the requirements, but I'm not sure if it is an oversight or not.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1016438]
help
Chatterbox?
[Eily]: LanX well since the onion is your eye you should see it everywhere
[marto]: sounds eye watering
[LanX]: oh your talking about my pic?
[Eily]: marto #SoSad
[holli]: duh
[marto]: I expect you to take a nice photo in Glasgow to replace this one :P
[Eily]: LanX yup, saw it when I checked your current rank
[LanX]: obviously the message is not clear enough if you only notice the onion now. ...
[Eily]: might have noticed before and forgotten
LanX has ideas for more similar pics

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (13)
As of 2017-12-14 16:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What programming language do you hate the most?




















    Results (398 votes). Check out past polls.

    Notices?