in reply to Re: Guess A Number
in thread Guess A Number

I appologize for the indending, people have been telling me lately it makes it all look funny and harder to read. I can't figure out the best way to indent anything so I'm stuck with what I got for the time being, sorry. == and eq always confused me and since it didn't show up as an error with the script I thought it was a lucky guess. On the next script update I'll change everything

Thanks

"Age is nothing more than an inaccurate number bestowed upon us at birth as just another means for others to judge and classify us"

sulfericacid

Replies are listed 'Best First'.
Re: Re: Re: Guess A Number
by Anonymous Monk on Mar 17, 2003 at 19:33 UTC
    Typical indenting styles indent a specified amount within every control structure. The specified amount is usually one of 2, 3, and 4 spaces. People also vary on the placement of braces.

    Whatever you do, the key is to pick a style and then be consistent. Mixing and matching and random indentation makes your code much harder to work with.

    If you are too lazy to pick a style, you can just download perltidy, run it on your scripts, and then accept the way that it does things.

      Thanks for the info on PerlTidy :P It took a while to figure out how to install because I had to download nmake and all that but the program does do the trick!

      Thanks again! PerlTidy is definately what I was looking for!

      "Age is nothing more than an inaccurate number bestowed upon us at birth as just another means for others to judge and classify us"

      sulfericacid

Re: Re: Re: Guess A Number
by artist (Parson) on Mar 17, 2003 at 18:07 UTC
    Hi sulfericacid
    If you use appropriate code-editor it will indent for you automatically as you type. I use emacs, and it works very well. Besides indenting there are lots of other features in emacs, like auto-typing , hiding certain code while developing, auto-ftp etc..

    example for indentation from your code:

    while ($tries < $allowed) { print " Your guess: "; chomp($guess = <STDIN>); $tries++; if ($guess eq $answer) { last; } elsif ($guess > $answer) { print " $guess is too high!\n"; } elsif ($guess < $answer) { print " $guess is too low!\n"; } }

    If you like to use emacs visit:http://www.gnu.org/software/emacs/. It's worth investment of time.

    One more point, make your code little modular. That would increase the readability also.

    artist

      I downloaded Emacs a few days past as someone in the CB said that it would automatically align the codes for you as well. After downloading it and searching through the help docs and asking in the CB no one was able to tell me how to get my code aligned. I ended up going with PerlTidy because that made my code all nice and pretty looking, lol.

      Thanks for the example indentation and the suggestion for Emacs.

      "Age is nothing more than an inaccurate number bestowed upon us at birth as just another means for others to judge and classify us"

      sulfericacid