TAILIEUCHUNG - tạo ứng dụng webchat phần 4

Tham khảo tài liệu 'tạo ứng dụng webchat phần 4', công nghệ thông tin, hệ điều hành phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả | Chapter 26 WebChat user information fields are joined by the pipe symbol and are written to the file as a single line. Finally the file is closed and the newly created session code is returned from the subroutine. open SESSIONFILE chat_session_dir session_file print SESSIONFILE join @fields print SESSIONFILE n close SESSIONFILE session End of MakeSessionFile The RemoveOldSessions Subroutine The RemoveOldSessions procedure goes into the chat_session_dir directory and removes all files that are older than chat_session_length. These variables are set up in . The @files array is used to contain all the filenames in the current directory. file is a temporary variable used to hold the filename of the current file that the program is checking for age. The directory is opened using the opendir command and the files in the directory are read to an array using the readdir command. The output from readdir is passed to Perl s internal grep function to make sure that the special filenames . and . escape the removal process. sub RemoveOldSessions local @files file opendir SESSIONDIR chat_session_dir @files grep . . readdir SESSIONDIR closedir SESSIONDIR The age of each file is then checked using the -M modification date operator. This operator returns the age of the file in days. If this age is greater than chat_session_length the unlink function is called to delete the file. foreach file @files 721 Chapter 26 WebChat If it is older than session_length delete it if -M chat_session_dir file chat_session_length . unlink chat_session_dir file End of RemoveOldSessions The RemoveOldWhoFiles Subroutine RemoveOldWhoFiles takes who files in the current chat directory and checks to see whether they are old enough to expire. If they are they are deleted. @files and file are declared as local variables that are used throughout the routine processing. sub RemoveOldWhoFiles local @files file The chat room directory is opened for reading by using the value stored in chat_room_dir a

TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.