Advertisement
Guest User

Untitled

a guest
Jul 21st, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 1.45 KB | None | 0 0
  1. # - # is the comment character in Perl, use this to toggle comments in your program. Also note that comments are ignored by the Perl interpreter.
  2.  
  3. #!/usr/bin/perl #This is something known as a shebang line, used these to associate your Perl program with the Perl bin / interpreter.
  4.  
  5. print("Who would you like to say hello to? "); #Prints the specified prompt-based text to the Perl console.
  6.  
  7. $user = <STDIN>; #This is a macro in Perl you use to receive input from the user.
  8.  
  9. chomp($user); #Removes the newline from the <STDIN> macro so it doesn't cause the Perl interpreter to have trouble validating user input.
  10.  
  11. #If, Else, ElseIf control structures.
  12.  
  13. if ($user eq "beeer") { #The keyword eq is used for case-sensitive procedures.
  14.     print "beeer maid? \n"; #\n is an escape character in Perl, it's used to start newlines, similar to the @CRLF macro in AutoIt.
  15. }
  16. elsif ($user eq "Protozoid") {
  17.     print "You hit the jackpot! Protozoid is winrar. ^___^ \n";
  18. }
  19. else { #If none of the blocks above are true (user is not Protozoid or beeer), execute the statement(s) after the else control structure.
  20.      print("hello, " . $user . "!" . "\n") #. is the concatenation operator in Perl. Use it to join strings together.
  21. }
  22.  
  23. $keep_alive = <STDIN>; #Using this at the end of your Perl scripts makes the interpreter assume that you're still trying to receive user input; use this to keep your Perl programs alive if you don't want the console to close immediately after everything is executed.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement