in reply to Re^2: Read two values from input
in thread Read two values from input

davido
i have written
"if you want to get the values in different variables directly"
and
"the first two lines of code are not compulsion here"
i think that explains that i know the user specifications
and used warning and strict because i have been told by many monks to do so
submitted the solution thinking that i would be beneficial for knils_r00t.
sorry if i am wrong

Replies are listed 'Best First'.
Re^4: Read two values from input
by davido (Cardinal) on Nov 25, 2011 at 06:01 UTC

    There is nothing wrong with using strict in your example, and there's no problem showing the shebang line either. As a matter of fact, I almost always use strict and warnings in example code I provide. But I usually don't make a big deal about it by mentioning it explicitly unless strict or warnings would have prevented the OP from running into trouble in his specific situation. It's one thing to demonstrate a good practice at work. It's another to confuse the intent of your solution with suggestions that are not related to the solution.

    My issues are these:

    • The original poster's example input showed two numbers on the same input line. If that is an accurate example (which we have to assume it is), your solution fails to work. Your solution will NOT end up putting two numbers into two different variables if both numbers are presented on one line of input. If you feel that your solution meets the OP's needs, you either still don't understand the question, or you don't understand your own code.
    • You directed the OP to review a node dedicated to using strictures, yet you gave no indication as to why you felt that is relevant to the problem (and in fact, it isn't). Consequently you sent the OP on a mission to read an irrelevant document. You might as well have suggested he read perlopentut; equally irrelevant to his problem. Perhaps you don't fully understand what 'strict' does. If you do understand, you might want to indicate in your post why you felt it's relevant.

    I think it's great that you're learning Perl and contributing to threads here. My advice is to be sure you understand the question, test the code in your responses, and do your best to keep your response relevant to the issue at hand.

    Please, by all means continue contributing. I'm trying to offer advice that will help you to improve the quality of your posts, and that will reduce the need for someone asking a question to have to distinguish between good advice and bad advice.

    Don't worry, we're all trying our best here to make Perl a great tool, and the Monastery a great place to learn to use it.


    Dave