Đang chuẩn bị liên kết để tải về tài liệu:
Minimal Perl For UNIX and Linux People 9

Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ

Từ một quan điểm Perlish, bạn có thể lựa chọn như là một loại đặc biệt của biến thể tương tác trên một vòng lặp foreach. Nhưng thay vì có mỗi danh sách giá trị được giao tự động để biến vòng lặp cho một lặp đi lặp lại, chọn chỉ gán giá trị khi họ được lựa chọn bởi người sử dụng. Tiếp theo, bạn sẽ thấy làm thế nào bạn có thể tránh những "phát minh lại bánh xe" bằng cách sử dụng vòng lặp này | From a Perlish perspective you can think of select as a special kind of interactive variation on a foreach loop. But rather than having each list-value assigned automatically to the loop variable for one iteration select only assigns values as they are selected by the user. Next you ll see how you can avoid re-inventing wheels by using this loop. 10.7.1 Avoiding the re-invention of the choose-from-a-menu wheel Although Perl has no counterpart to the Shell s handy select loop its functionality is provided by a CPAN module called Shell POSIX Select.21 It provides its services through source-code filtering which means it extracts the select loops from your program and rewrites them using native Perl features. As a result you can use a feature that s missing from Perl as if it were there The benefit of bringing the select loop to Perl is that it obviates the need for terminal applications to provide their own implementations of the choosefrom-a-menu code which indulges the programmer s noble craving for Laziness and thereby increases productivity. Table 10.9 shows the syntax variations for the Shell s version of the select loop. Table 10.9 The Shell s select loop select var do commands done Form 0 select var in LIST do commands done Form 1 If in LIST is omitted as in Form 0 in @ is used by default to provide automatic processing of the script s or function s argument list. Some of the major forms of Perl s select loop are shown in table 10.10. These take their inspiration from the Shell and then add enhancements for greater friendliness and well Perlishness. Table 10.10 The select loop for Perl use Shell POSIX Select select Form 0 select CODE Form 1 select LIST CODE Form 2 select var LIST CODE Form 3 As you can see Perl s select lets you omit any or even all of its components apart from the punctuation symbols . For example if the loop variable is omitted as in Forms 0 1 and 2 _ is used by default. If the LIST is omitted as in Forms 0 and 1 the appropriate arguments .

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.