in reply to Re: New to Perl
in thread New to Perl

While I appreciate the time you've taken to help, I must say, I don't appreciate the way you've done it. You have given a nearly complete solution to someone asking for pointers on how to start. I'm sure you've heard the old proverb about teaching someone to fish rather than giving them a fish...

Now, you may go on about how your code was intended to be a useful example to learn by, but I can't entirely agree. It's not commented, quite dense, and, frankly, doesn't exactly use what I would call good style. It works, and there's something to be said for that, but I'm dubious about using such examples for pedagogical purposes.

Replies are listed 'Best First'.
Re^3: New to Perl
by Random_Walk (Prior) on Jan 20, 2005 at 18:42 UTC

    You are probably right. I started playing with this and it took longer than I thought so I did not get time to comment the code, I thought as I had written it I may as well post it. It answered at least one of the OPs questions, can perl do this ;)

    The data structure is not exactly beginers stuff but as we did not have any spec for output I thought that was the easiest way to show that it can be done. Now we have an output spec I would (shall if I get time this evening) re-write it so it prints the data as it finds it removing the need for a Hash of Arrays of God knows what.

    Cheers,
    R.

    Pereant, qui ante nos nostra dixerunt!
Re^3: New to Perl
by renz (Scribe) on Jan 20, 2005 at 19:49 UTC
    I respectfully disagree with you. It is not that he has given you a fish as much as he has built the pole for you. If it doesn't meet your standards, then that particular pole serves at least as a reference point for building your own.

    I don't mind the style that much, though I would never say my $scalar="bleh"; before I said my($scalar) = "bleh";. But that's just me. I'm probably one of the few people left who puts parens around a single my arg. Of course, that's an OCD thing more than anything else. Anyway, I've never thought that getting nit-picky about another person's perl style was polite. If TIMTOWTDI and the interpreter doesn't ultimately care what method is chosen, I don't think it's up to you or anyone else to chastise another programmer for his style. It just seems un-perl to me.

    I don't know if your intention was to be "politely rude" so to speak, but it comes off that way. What was wrong with simply saying "thanks for taking time out of your day to assist me" and disregarding the rest of what you felt you HAD to post. I could be interpreting that wrong, so I'm telling you how I heard it and giving you the opportunity to correct me.

    I think this is the first node I've read where working code was frowned upon.

    /renz.

    UPDATE: Ugh. tall_man: bad example on my part. You're right. Humorously enough I finally gave up my desire to put parens before everything, some time after posting this, and for the very reason you have given. I just neglected to modify this post (mainly because I forgot about it). As of late I have labored greatly to conform to perldoc perlstyle as much as possible, though I have never preferred a 4-column indent to a 2-column indent, and I find it difficult not to cuddle my elses.
      I agree with what you say; providing some code in answer to a question is entirely appropriate most of the time.

      The nit I have is that you say there is no difference other than style between my $scalar="bleh"; and my($scalar) = "bleh";. There is a difference. The former uses scalar context and the latter uses list context. That can make a difference to the evaluation of an expression. For example:

      use strict; my $time1 = localtime(); my($time2) = localtime(); print "time1 is $time1\n"; print "time2 is $time2\n";

      The time2 line prints only the seconds value of the current time.