#!/usr/bin/Perl # The standard header for any perl script that specifies where to find the # Perl interpreter used to run the following script print <; # Reads the entire file into a variable called $source. Because $/ # was undefined previously, this reads the entire file (it's called # a "slurp" when this happens) close SOURCE; # Closes the file, ie we no longer need to access the file. $beginning = index($source, 'antiTHESIS') + 13; # Searches through the variable $source for the first appearance # of the string "antiTHESIS". When it has found the character position, # it stores this in $beginning and adds 13 to it (which is the length # of the string "antiTHESIS") $end = index($source, 'antiTHESIS', $beginning + 1) - 1; # Searches through the variable $source, starting at the character # position we just found, for the next occurance of the string # "antiTHESIS", storing this second character position in a # variable called $end, but subtracts 1 from it $byte1 = $beginning + rand($end - $beginning); # Picks a first random number between $beginning and $end $byte2 = $beginning + rand($end - $beginning); # Picks a second random number between $beginning and $end (substr($source, $byte1, 1), substr($source, $byte2, 1)) = (substr($source, $byte2, 1), substr($source, $byte1, 1)); # Swaps the two characters in the string $source at the positions $byte1 and $byte2 # Most languages wont let you do this is one go, you have to use a third # temporary variable while you switch over the values. However in Perl you # can do this by implying two temporary lists, the first one references # the characters (ie. substrings) at positions $byte1 and $byte2, the # second list contains the actual characters at positions $byte2 and $byte1 # (note the swapped order in the second list) open SOURCE, ">$0"; # Creates a file handle (also called SOURCE, although it's an entirely # new handle) by opening for output (>) and thus creating a blank file # with the name of the script's own source file ($0). This is a # self-destructive action, since if the script crashes between here # and it succesfully writing the file, it will have erased it's own # source code forever. print SOURCE $source; # Write the contents of the variable $source to the file handle SOURCE close SOURCE; # As before, closes the file handle. if ($source !~ /disorder can lead to a sense of new order/) { # A conditional: everything between here and the closing } will only # execute if the variable $source *DOES NOT* contain a string that says # "disorder can lead to a new sense of order" - this is achieved by using a # simple regular expression (denoted by the !~ and two /slashes/) # ...The ! represents the 'NOT' condition $ftp = Net::FTP->new("thesis.anti-thesis.net"); # Create an object from the Net::FTP library that will connect to the # server thesis.anti-thesis.net $ftp -> login("antithesis", "sisehtitna"); # Gets the object to log into the server using a username and password $ftp -> cwd("Sites"); # Gets the object to change directory to "Sites" on the remote server $ftp -> put($0); # Gets the object to upload (PUT) a file onto the FTP server. The # file to upload is the script's own source file ($0) $ftp -> quit; # Gets the object to close the connection and quit doing any FTP # activity } # The end of the conditional segment