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

I'm currently learning Perl and a while ago I had a problem with some coursework.

I signed up to this forum and was overwhelmed with the response.

One reply in particular was a bit dis-heartning and I concluded that Perl Monks isn't for me.

I realize there are a lot of hardcore Perl programmers on here, but I only signed up to get help with my problem, not to become a Perl Monk.

Now I have another problem and am afraid to post it on here. I enjoy solving problems but sometimes I need a little help. My course tutors aren't very helpful!

Could anyone suggest another forum perhaps where there are other students like myself who are in the same boat?

Replies are listed 'Best First'.
Re: Perl Help
by marto (Cardinal) on Jan 22, 2008 at 11:14 UTC
Re: Perl Help
by svenXY (Deacon) on Jan 22, 2008 at 11:10 UTC
    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!
      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); }
Re: Perl Help
by Slug (Acolyte) on Jan 22, 2008 at 11:25 UTC
    Perl Monks has been helpful, and I would have struggled for ages without it. I didn't know much about it when I signed on to it. I had just seen it whilst browsing ages back. I got the impression from one poster on a previous problem that it was an elitists forum, perhaps he was in a bad mood. Thanks for the advice.
Re: Perl Help
by Slug (Acolyte) on Jan 22, 2008 at 11:31 UTC
    (For coursework) I've got to write a script which counts certain characters within a text file. I'm looking for hyphens, open and closed brackets, full stops and commas. I know how to read a file line by line. I was going to write a regular expression to scan each line, and increment a variable by one for each instance of the character found. Is there a better method for doing this?
      Regexes aren't good for counting anything. (Yes, there are regex hacks that count things, but we leave that aside for a moment...)

      You should traverse your lines char by char and then check (perhaps with a regex, or with a hash lookup) if the char is interesting to you.

      You want something like this:
      my %hist; while(<$fh>){ ++$hist{ $_ } for split //; } for(sort{ $hist{ $b } <=> $hist{ $a } } keys %hist){ print "'$_' => $hist{ $_ }\n"; }
      but you need to filter out the chars you don't want.
Re: Perl Help
by Slug (Acolyte) on Jan 22, 2008 at 11:42 UTC
    Another question? How do I return the amount of a certain character within a string? I've googled it and found the split command but it seems excessive?
      You may want to look at the responses to this post. I think your answer lurks in there =)


      Smoothie, smoothie, hundre prosent naturlig!