supernewbie has asked for the wisdom of the Perl Monks concerning the following question:

Formerly titled: How do I find out many letter "f" are used in two paragraphs with PERL programming.. Please save a newbie's life... please...

WITH PERL, how can I find out how many letter "f" are used in two paragraphs like these:

sdfsdf adsfasdf sdfads dfasdf dsfasd sdfsdf sfdsaf fdedx dffgs gfefsddf kfef ldkjikk. feal kddfdl dfdafdfasd, sdfioddff, ffokjmimiijij, fdfsdfsdfd, feefffdd fdflnnjdf, feffdsdfds, sdfd safad fdafdfsd asdfds.

adfasdfasdfsad; adfasdfdasf; aiodfd, aiihaf iddkkj jijlkjj fidlkj fdklkk fdllinn lkjljkljljkk fdiii sdadl lsjijdf idfasd, ajdfia, kijijl fllijj jliiljnf jjijjil.

Do I use m// or something else? HOW?
Thanks a million for saving a newbie from dying...

Edited by footpad, 18 Jul 01 - 12:45 pm (PDT)

Replies are listed 'Best First'.
Re: Counting F's
by runrig (Abbot) on Jul 18, 2001 at 21:17 UTC
    Read perlop on tr:
    my $count_effs = $paragraph =~ tr/f//;

    Edited by footpad, 18 Jul 01 - 12:49 PM (PDT)

Re: Counting F's (Was: How do I...)
by petdance (Parson) on Jul 19, 2001 at 05:18 UTC
    Maybe he's trying to solve that old chestnut of counting the Fs in the following block of text:
    FINISHED FILES ARE THE
    RESULT OF YEARS OF SCIENTIFIC
    STUDY COMBINED WITH THE
    EXPERIENCE OF YEARS.
    

    xoxo,
    Andy
    --
    <megaphone> Throw down the gun and tiara and come out of the float! </megaphone>

Re: Counting F's
by merlyn (Sage) on Jul 18, 2001 at 23:36 UTC
    The fact that it's the letter "f" and not something more interesting like \n makes me think this is homework. Can we get a better explanation of the problem here?

    -- Randal L. Schwartz, Perl hacker

    Edited by footpad, 18 Jul 01 - 12:51 pm (PDT)