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

Re: Re: hard referencing in hashes?!?

by ph0enix (Friar)
on Nov 08, 2002 at 11:05 UTC ( [id://211403]=note: print w/replies, xml ) Need Help??


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

map { $word_list{$_}++ } @words;

Replies are listed 'Best First'.
Re: Re: Re: hard referencing in hashes?!?
by jdporter (Paladin) on Nov 08, 2002 at 12:50 UTC
    $word_list{$_}++ for @words; @sorted = sort keys %word_list;
      @word_list{@words}=1; @sorted = sort keys %word_list;

      update:
      Oh come on, that shift+9 shift+0 ... 3 extra keys man ... *me*shakes*head* ... whatever happened to lazyness ???

      :D

      ____________________________________________________
      ** The Third rule of perl club is a statement of fact: pod is sexy.

      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?
        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.

Log In?
Username:
Password:

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

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

    No recent polls found