in reply to counting words in string
Hash free ! :)
#!/usr/bin/perl -l use strict; use warnings; $_ = "iowq john stepy andy anne alic bert stepy anne bert andy step al +ic andy"; print "$& => ", s/\b$&\b//g while /\w+/;
Outputs:
iowq => 1 john => 1 stepy => 2 andy => 3 anne => 2 alic => 2 bert => 2 step => 1
|
|---|