in reply to Perl Help

Hi,
glad you made it back here!

Almost everybody is probably willing to even help you with your coursework (a.k.a homework) if you first show us what you have tried yourself.

Few will probably be eager to wrtite your coursework for you though.

You get the point? Good! No? Read How (Not) To Ask A Question (especially "Do your own work") and then ask your question.

Looking forward to your post,
svenXY

PS: I'm not a hardcore perl programmer and many of us aren't either
PPS: Most of us have started they way you (hopefully) do now!

Replies are listed 'Best First'.
Re^2: Perl Help
by Slug (Acolyte) on Jan 22, 2008 at 11:56 UTC
    I'm trying to count the instances of certain characters within a text file. Here is what I have written so far. I'm having a problem with the brackets. Its picking them up as character classes. Help.
    open (READFILE, "<readme.txt") || die "Couldn't open file: $!"; $buffer = ""; while(<READFILE>) { $commas++ while ($_ =~ m/,/g); $fullstops++ while ($_ =~ m/\./g); $openbracket++ while ($_ =~ m/[/g); $closedbracket++ while ($_ =~ m/]/g); $hypehns++ while ($_ =~ m/-/g); }
        I still can't get it to pick up brackets. Please help? Is there an ASCII equivelent I can search for.
        open (READFILE, "<readme.txt") || die "Couldn't open file: $!"; $buffer = ""; while(<READFILE>) { #print $_; $commas++ while ($_ =~ m/,/g); $fullstops++ while ($_ =~ m/\./g); $openbracket++ while ($_ =~ m/\[/g); $closedbracket++ while ($_ =~ m/\]/g); $hyphens++ while ($_ =~ m/-/g); } print ("$commas commas\n"); print ("$fullstops full stops\n"); print ("$openbracket open brackets\n"); print ("$closedbracket closed brackets\n"); print ("$hyphens hyphens\n");