in reply to Could I get some feedback on my code please?

Hi PockMonk,

I'm in a very similar boat to yourself. I'm not able to run your code but just from reading it I think it looks fine. And if it works that surely must be a bonus. :-)

I would like to make a few points and ask a couple of questions.

The list of 23 regexes in fetchArticleCreator() to extract data from HTML could be replaced by using an HTML parser.

To add to f00li5h's very good point about taking the HTML 'guff' out of your script. You don't appear to be using CGI.pm for any output. I don't either so I moved over to using CGI::Simple. The docs discuss why you might consider doing the same.

Minor nits.

I find using all uppercase for globals helps make my scripts clearer. Why do you "our" instead of "my"?

imo I think CGI scripts in particular benefit from the 3 argument open. I also always use a lexical file handle to avoid the bareword.

For my own curiosity:

Why do your subs checkForUnexpectedArgs()? All the subs are called from within the script so I'm not sure how useful the user will find that message.

When would checkFileCanBeAccessed() return and a subsequent open die? Wouldn't or error("$msg $!") on the open be enough? I have some major rewriting to do if it isn't. :-)

Hope that helps.

Replies are listed 'Best First'.
Re^2: Could I get some feedback on my code please?
by PockMonk (Beadle) on Jan 13, 2007 at 11:49 UTC

    Thanks for the response, lots to get my teeth into there:

    The list of 23 regexes in fetchArticleCreator() to extract data from HTML could be replaced by using an HTML parser.

    Could you explain this in more detail please?

    To add to f00li5h's very good point about taking the HTML 'guff' out of your script. You don't appear to be using CGI.pm for any output. I don't either so I moved over to using CGI::Simple. The docs discuss why you might consider doing the same

    I've just revised the script to take account of HTML::Template as suggested, I should look into CGI::Simple shortly as advised.

    I find using all uppercase for globals helps make my scripts clearer. Why do you "our" instead of "my"?

    I'm guessing probably because I don't truly understand globalsand aren't using them properly! :-P

    imo I think CGI scripts in particular benefit from the 3 argument open. I also always use a lexical file handle to avoid the bareword

    Thanks, I'll look into that on the link provided.

    Why do your subs checkForUnexpectedArgs()? All the subs are called from within the script so I'm not sure how useful the user will find that message

    The script isn't complete yet and I find it helpful while debugging etc to catch anything I've passed accidentally when I'm chopping and changing what gets passed to what.

    When would checkFileCanBeAccessed() return and a subsequent open die? Wouldn't or error("$msg $!") on the open be enough? I have some major rewriting to do if it isn't. :-)

    I'm sure that you're right, actually. I guess that bit is a bit redundant...

    Thanks!