Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: Seeking a better way to do it

by frozenwithjoy (Curate)
on Feb 01, 2013 at 05:20 UTC ( #1016439=note: print w/ replies, xml ) Need Help??


in reply to Seeking a better way to do it

What is your rule for extracting 'Iago' and 'Othello'? Do you also mean to extract 'Enter' (another word that starts w/ a cap)?

You said your solution works, but you write plit instead of split and I get other errors. Can you update it with functional code?


Comment on Re: Seeking a better way to do it
Select or Download Code
Re^2: Seeking a better way to do it
by Khen1950fx (Canon) on Feb 01, 2013 at 05:27 UTC
    I think the OP meant 'Iago' and 'Othello', so maybe something similar to this:
    #!/usr/bin/perl -l use strict; use warnings; my ($char_list) = "Enter Iago, Othello, and others"; my (@words) = split( /\W/, $char_list, 0 ); foreach my $word (@words) { if ( $word =~ m/[F-Z]\w+/g ) { push my (@entering_chars), $word; print "@entering_chars"; } }

      But starX's script also gives "Enter" word in the output. I guess he/she need to extract words contains Upper case letter

      Ya, we really need more info. Limiting the first letter to F through Z is not very portable. If you already know the words you want (and choose the letters accordingly), you might as well name the words specifically.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (11)
As of 2015-07-06 07:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (70 votes), past polls