in reply to Re^7: seeking advice on loops
in thread seeking advice on loops

You have given great advice and I really thank you. I am ready to submit my assignment; however you get 40 points for turning that foreach loop into a subroutine. Everytime I try the script with the foreach loop in a subroutine I get errors (uninitialized value errors).

The assignment is worth 200 points. Some points are for coding style. When you say be consistent with the style do you mean that you indent a certain amount of spaces every time for a while, for, foreach, etc... function? I tried to stay consistent.

I just wanted to thank you for your guidance. Now the class is back to the O Reilly book and homework at the end of the chapters. The final is a huge ordeal as it you have to write a unix adminsitration script (add a new user, check to see if the name exists, generate a random password using the username, etc...) - I hope the O Reilly book can assist with the writing of this script!

Thank you Tanktalus

Sierra

Replies are listed 'Best First'.
Re^9: seeking advice on loops
by Tanktalus (Canon) on Oct 11, 2005 at 23:22 UTC

    So, the question is ... what is it that you're trying, what are the exact error messages you're getting, and, if possible, what do you think the problem is? (I would suggest this going into a new thread at this point - almost no one but me will read your response to this at this point because of the high number associated with the "Re" in the subject line ;-})

    As to your style question: by consistancy, I mean that inside a single block, each line should line up on the left. Don't indent a print statement by 2 spaces, and then the following statement indent by 4. And then a few lines later, go back to only 2 spaces. Each block should indent by the same amount so that similarly-indented lines of code should be buried in similarly-deep blocks. Bad:

    if ($something) { print "here\n"; $count++; call_something(); print "here2\n"; get_input(); }
    Good:
    if ($something) { print "here\n"; $count++; call_something(); print "here2\n"; get_input(); }
    Hope that helps.