TAILIEUCHUNG - Minimal Perl For UNIX and Linux People 7

Điều này đảm bảo rằng chương trình sẽ chết nếu $ câu trả lời là không xác định, và cũng là câu trả lời $ sẽ không được so sánh "YES \ n", trừ khi nó có một giá trị được xác định. Đó là tài sản cuối cùng circumvents việc sử dụng một giá trị chế tạo trong việc so sánh sự bất bình đẳng, và "giá trị uninitialized" cảnh báo mà đi với nó. Với điều chỉnh này, nếu $ câu trả lời là không xác định, chương trình có thể chấm dứt mà không có một cảnh. | answer as undefined This signifies that the variable has been brought into existence but not yet given a usable value. The solution is to add an additional check using the defined function like so defined answer or answer ne YES n and die n 0 Hasty resignation averted n This ensures that the program will die if answer is undefined and also that answer won t be compared to YES n unless it has a defined value. That last property circumvents the use of a fabricated value in the inequality comparison and the uninitialized value warning that goes with it. With this adjustment if answer is undefined the program can terminate without a scary-looking warning disturbing the The rule for avoiding the accidental use of undefined values and triggering the warnings they generate is this Always test a value that might be undefined for being defined before attempting to use that value. But there is an exception copying a value as in got_switch never triggers a warning even when answer is undefined. That s because moving undefined values around as opposed to using them in significant ways is considered a harmless activity. Tips on using defined The following statement attempts to set got_switch to a True False value according to whether any or all of the script s switches was provided on the command line got_switch defined debug or defined verbose WRONG Here s the warning it generates Useless use of defined operator in void context That message arises because the assignment operator has higher precedence than the logical or causing the statement to be interpreted as if it had been typed like this 4 got_switch defined debug or defined verbose Perl s warning tells the programmer that it was useless to include the or defined part because there s no way for its result to be used anywhere . it s in a void context . As with other problems based on operator precedence the fix is to add explicit parentheses to indicate which expressions need to be evaluated before others .

TỪ KHÓA LIÊN QUAN
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.