or this:while (<USEDPW>) { my $pw = @chars[map{rand @chars} (1..17)]; } unless ($_ ne $usedpw) { print "Your unique ID is: $pw\n"; }
Whether you like to hug the open brace (example 1) or put it's on it's own line (example 2) is a matter of personal preference - both are correct. However, you really need to line the closing brace up with what started it. Also, i recommend using tabs instead of spaces - you can always use a tool like expand to convert each tab to any number of spaces. For comments to the left of code, well, i try to avoid them, but when i have to have to have them i use spaces to line them up. Keep up the good work. :)while (<USEDPW>) { my $pw = @chars[map{rand @chars} (1..17)]; } unless ($_ ne $usedpw) { print "Your unique ID is: $pw\n"; }
Oh yeah ... you can simplify the unless block like so:
... and double negatives are bad habits, notice that i replaced unless with if and ne with eq.print "Your unique ID is: $pw\n" if $_ eq $usedpw;
jeffa
L-LL-L--L-LL-L--L-LL-L-- -R--R-RR-R--R-RR-R--R-RR B--B--B--B--B--B--B--B-- H---H---H---H---H---H--- (the triplet paradiddle with high-hat)
In reply to (jeffa) 2Re: Losing or overwritting values
by jeffa
in thread Losing or overwritting values
by sulfericacid
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |