print "Welcome to the Library of Alex, located directly under the Library of Babel."; sleep(4); MainScreen();
sub MainScreen{ print "\n\n"; print "What would you like to do?\n"; print "1. Find random book.\n"; print "2. Find specific book. **Out of Order**\n"; print "3. About the Library of Alex\n"; print "4. Exit Library Program.\n"; $answer = <>;
if ($answer == "1"){ RandomBook(); } if ($answer == "2"){ print "Being as there are more books here than the number of atoms in the universe, it is taking us some time to cataloged everything. Please try again later."; MainScreen(); } if ($answer == "3"){ print "\nThe Library of Babel above us contains every possible combination of basic characters (letters, spaces and punctuation marks) for a 410-page book. 'Who has time for that?' says the Alex, the lead librarian for The Library of Alex. His library instead of containing every possible combination of 410 page books, instead houses every single flash story of 10000 characters."; MainScreen(); } if ($answer == "4"){ exit(); } else{ print "\nThat's not a valid selection!"; MainScreen(); } }
sub RandomBook{ # This is the characters array for the story # It has every letter in upper and lowercase, and . ! ? in punctionation marks
@letters = PRETEND $x = 0; $book = "";
#Gets book while ($x < 10000){ my $range = 57; # Number in array + 1 my $random_number = int(rand($range));
$book = join $book, "", $letters[$random_number];
$x++; }
unlink("book.txt");
open (MYFILE, ">>book.txt"); print MYFILE "$book"; close (MYFILE);
print "Your book has been selected! Please go to the location of this program and readthe book text document."; MainScreen(); }
Where the @letters array is, pretend there is the array there. LW has that thing about 100 characters in a row.
I borrowed some code from the repository and it was perfectly readable even without comments.
That kinda code makes me want to give the person a handjob
Quote: from Sector Corrupt at 10:20 pm on June 11, 2009 Least it's a good habit. I currently only comment when I'm stuck and need something to keep me busy while I think out the problem. That, and my work I think is a little lax on the whole code thing, as long as it works. God I hate people who don't comment. Makes my life hell when I have to clean up after them
Least it's a good habit. I currently only comment when I'm stuck and need something to keep me busy while I think out the problem. That, and my work I think is a little lax on the whole code thing, as long as it works.
God I hate people who don't comment. Makes my life hell when I have to clean up after them
Yeah, were anyone working on my project beside me I'd make sure to comment as I go along, but for now I mostly only pepper comments here or there and leave it to be cleaned up when I'm done. Right now I'm just trying to get a version we can roll out to our remote boxes.
But yeah, good commenting is great. Or at least clear code. I borrowed some code from the repository and it was perfectly readable even without comments.
Quote: from Sector Corrupt at 3:20 am on June 11, 2009 Fairly interesting, and the first time I've seen Perl used on LW oddly enough, sans my signature. Plus it's nice seeing clear code that is readable in perl, after hacking together my overly complicated script... But oh well, such is life. Concerning readable code, I blame my teacher. She counted off if we didn't have comments in the code, and counted off more if someone couldn't understand it without the comments.
Fairly interesting, and the first time I've seen Perl used on LW oddly enough, sans my signature. Plus it's nice seeing clear code that is readable in perl, after hacking together my overly complicated script... But oh well, such is life.
Concerning readable code, I blame my teacher. She counted off if we didn't have comments in the code, and counted off more if someone couldn't understand it without the comments.