TAILIEUCHUNG - Perl in a Nutshell phần 4

ba yếu tố điều hành có điều kiện: là các nhà điều hành có điều kiện. Nó hoạt động giống như một câu lệnh if-then-else, nhưng nó một cách an toàn có thể được nhúng trong các hoạt động khác và các chức năng. tNếu được đánh giá. Nếu không, chỉ if_false_expr được đánh giá. | Chapter 4 References and Complex Data Structures 41 PREVIOUS Chapter 4 The Perl Language NEXT References and Complex Data Structures A Perl reference is a fundamental data type that points to another piece of data or code. A reference knows the location of the information and what type of data is stored there. A reference is a scalar and can be used anywhere a scalar can be used. Any array element or hash value can contain a reference a hash key cannot contain a reference and this is how nested data structures are built in Perl. You can construct lists containing references to other lists which can contain references to hashes and so on. Creating References You can create a reference to an existing variable or subroutine by prefixing it with a backslash a fondue @alist pitt hanks cage cruise song mother crying brother dying sub freaky_friday s mother daughter Create references ra a ralist @alist rsong song rsub freaky_friday required for subroutine names References to scalar constants are created similarly pi myname Charlie Note that all references are prefixed by a even if they refer to an array or hash. All references are scalars thus you can copy a reference to another scalar or even reference another reference aref @names bref aref both refer to @names cref aref cref is a reference to aref Because arrays and hashes are collections of scalars you can create references to individual elements by prefixing their names with backslashes star alist 2 refers to third element of @alist http documents oreilly perl perlnut 1 of 3 2 7 2001 10 30 05 PM Chapter 4 References and Complex Data Structures action song mother refers to the mother value of song Referencing anonymous data It is also possible to take references to literal data not stored in a variable. This data is called anonymous because it is not bound to any named variable. To create a reference to a scalar constant simply backslash

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