in reply to Re: Re: Re: hard referencing in hashes?!?
in thread hard referencing in hashes?!?

Thanks for all your help guys! I was wondering how I would be able to get word123 into my @word but not 456. So that word123 would be a word, but 456 isn't a word. Right now I have
my @words = map {s/[.,!\W\?]\B//g; split; } <FILE>;
With this i'm getting it to keep word123 but if its 39 it would remove the 3 but not the 9? Also if I add an i (case insensitive) behind the /g would that give me There = there?

Replies are listed 'Best First'.
Re: Re: Re: Re: Re: hard referencing in hashes?!?
by jdporter (Paladin) on Nov 08, 2002 at 16:50 UTC
    It doesn't seem to me that you want to be altering any of the words; you're writing a pure filter. (Right?)

    So I'd probably do this:

    my @words = grep { /^[a-z]/i } map { split } <FILE>;
    The map produces a list of all the "words" in the file; the grep filters out any that don't begin with a letter. If you need to remove punctuation and stuff like that (if you said you did, I missed that), then you could modify the split accordingly:         map { split /\W+/ } hth,

    jdporter
    ...porque es dificil estar guapo y blanco.