TAILIEUCHUNG - Minimal Perl For UNIX and Linux People 10

$ CL_VERBOSE=2 check_links Got 101 links for 85 links are unique Checking '': OKAY Checking '': OKAY . BAD: '', in '' $ CL_VERBOSE=3 check_links # Output edited to fit Got 101 links for 85 links are unique Checking '': OKAY Type: text/html Size: N/A Server: Apache/ . Checking '': OKAY Type: text/html Size: N/A Server: Apache/ . . BAD: '', in '' Verbosity level 3 dumps out the data obtained by the head function from the web server, if any; otherwise it reports the link being tested as “BAD”. Now look at the script, which is. | CL_VERBOSE 2 check_links Got 101 links for 85 links are unique Checking http D A OKAY Checking http M A OKAY . BAD https in CL_VERBOSE 3 check_links Output edited to fit Got 101 links for 85 links are unique Checking http D A OKAY Type text html Size N A Server Apache . Checking http M A OKAY Type text html Size N A Server Apache . . BAD https in Verbosity level 3 dumps out the data obtained by the head function from the web server if any otherwise it reports the link being tested as BAD . Now look at the script which is presented in listing . It begins by importing LWP Simple which exports the head function automatically. It then checks for the variable CL_VERBOSE in the environment if it has a number in it that number is copied to the file-scoped variable VERBOSE so the requested verbosity level can conveniently be determined from anywhere within the program. On Line 25 the lwp-request command obtains the list of links found within the current page and then if tests the True False value of the array @links to determine whether links were found. Many pages contain multiple links to other pages so Line 32 filters the duplicates out of @links we ll come back to this . Listing The check_links script 1 usr local bin perl -wl 2 3 use strict 4 use LWP Simple 5 6 my VERBOSE 0 file scope 7 defined ENV CL_VERBOSE and ENV CL_VERBOSE A d and 8 VERBOSE ENV CL_VERBOSE if numeric value assign 9 10 MAIN program 11 foreach my url @ARGV check_link url 12 13 14 END 15 If propeller was last thing written to screen 16 will need n before shell s upcoming prompt to STDERR 17 print STDERR 18 406 CHAPTER 12 Modules and the CPAN 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 sub check_link my

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.