O’Reilly Mastering Perl 2007 phần 8

Chuỗi gói tạo ra trong trường hợp này là ngắn hơn so với chỉ dây cùng các ký tự tạo nên các dữ liệu, và chắc chắn không phải là dễ dàng để đọc: Đóng gói chuỗi có chiều dài [9] đóng gói chuỗi . Không giống như một hoạt động, một hành động nhập cảnh được coi là noninterruptible. Trong khi đăng một bản ghi lịch trình để sử dụng trên | The string that pack creates in this case is shorter than just stringing together the characters that make up the data and certainly not as easy to read Packed string has length 9 Packed string is DAKEt Per 1 The lormatsrriiigNCA hri onektterforeich ofihirestorthe aiguments and tells pack how to treatsits argument as a network-order unsigned long. The c treats its apgumentasahunsigneUchar and the A treats its argument as an ASCII character. After tho a . . t Ni Eei toLcrr te apply ft io rl t r . . . ic argument. WetDeut Oe i ir would oty pack the ftort cAracton tn Perl. Once I haos my paokedstrinc Iaanwritcitfoafili Nendit oprr asockft or aiiAthmg else I can dt with rerlngs. when I want to get back my data e uso unpack with the samo template strong my 100 acPtN AsciO h eencrf fNC1o UgfckfC ft ltnr 1N prim ntKt Ị Long 1oao Ctar khar ASCII ascii HERE As long as I ve Sone esetythrng correctly I get back the data I had when I started Long 31415926 Char 32 I can pack severeldata tsgether to form a record for a flat file database. Suppose my record comprise the ISBN title and author for a book. I can use three different A formats givinn yaahakngth specifier. For each length pack will either truncate the argument li It S Ooo et pad tl wfth spacer er Alt chieeet my Sirri tiieo Ornthor i AAN652it4ia rN1ttrgnk Port I brtan d fey I my Srecord pack A10A20A20 Srsbni stitle Sauthor ft i i -t print Record record n The record IS exnctly5r e - . no matter whtahdatal grveit Record O596527241Mastering Perl brian d toy . -1 When I store this in a file along with several other records I always know that the next 50 bytes sai a R putt me incbrrigbiposicioii ird I can read an exact numbteotbygeswith rvaeead open my trft fir . seek fh hn r ARNV e t e mspe torgghc .erorO 220 I Chapter 14 Drta Persistence sysread fh my Srecord 50 read next record. There are many other formats I can use in the template string including every sort of number .

Không thể tạo bản xem trước, hãy bấm tải xuống
TỪ KHÓA LIÊN QUAN
TÀI LIỆU MỚI ĐĂNG
Đã 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.