$random_file = "test.txt"; open (FILE, $random_file); @LINES=; close(FILE); srand; # Choose a random line #scalar(@LINES) is the number of elements in the array $OTP = "$LINES[(int rand(scalar(@LINES)))]"; $PWFILE = $OTP; open (FILENEW, ">$random_file"); foreach $LINES (@LINES) { if ($PWFILE eq $LINES){ $LINES = "" } else { print FILENEW $LINES; } } close (FILENEW); # If you want to remove the newline, I don't know much # about html stuff...it may cause problems? #chomp( $OTP ); $PPP = $OTP; #### test test1 test2 test3 test4