Help for this page

Select Code to Download


  1. or download this
    sub addbuddy {
    
    #add victim to buddy list
          #open names file 
        open (FILE, "names.txt");
    
  2. or download this
        $list = <FILE>;
    
  3. or download this
        close(DATA);
    
        #checks each name 
        foreach $item (@list) {
    
  4. or download this
        #remove lowercase and spaces from names
        $item =~ s/ //g;
        $item = lc ($item);
    
  5. or download this
        }
         
         #check if name is in file
         if ($victim eq "$item") {
    
  6. or download this
         }
         else {
    
          #if it does not exits add it
         open (DATA, ">names.txt");
    
  7. or download this
         print DATA "$victim\n";
         Close (DATA);
    
  8. or download this
         }
          #Notify the terminal
         print "A Buddy name was added..";
    }