tailieunhanh - O’Reilly Mastering Perl 2007 phần 10

Khi tôi có tất cả là tại chỗ, FETCH của tôi phương pháp có thể sử dụng nó để trở về một phần tử. Nó được các mẫu bit sau đó nhìn lên rằng mô hình với Các phương pháp Store sẽ làm tất cả những điều đó nhưng cách khác xung quanh. Biến các biểu tượng vào mô hình bit, thay đổi là tăng số tiền phải, | Once I got all of that in place my FETCH method can use it to return an element. It gets the bit pattern then looks up that pattern with _get_value_by_pattern to turn the bits into the symbolic version . T A c G . The STORE metho ddoes all that buttheotherv y bit pattern shiftsthatointhh riddtamo Uht and hoe s thn rightbitoperationstosesthb value. I ensure thaf t sleartlif larget bitsfirstusing the mask I get back from _get_clearing__mask. Once lataar the iabget bitn lean usb the bit aensk from _get_settiìeo aee lo SCynaorbOhnetement. Whew Dici you make it thin htre I haven t etan tmplemenfed all of tht array feetuees. How am I goingtptmsrement SHUT u eSHiFT Oh tp titot Here s e hinl bememher that Perl has togothitlorrealarras saiideifmgt h stet he lmoving things over every time I affect theffntit oftheedia lakeeps trackoe here itehoulhotart whtohm1ght not Oe the beginning ohthedala. ts Iwaetrhlo shift offasrngls element Itusf laaveto ehd that offset of ihreedito to ail of myc amputationt. nOe ftesttitmc ntwonldheof dtctd to 5 instead of 0 to leave that up to you though. e gi tt Hashes Tied hashes are only a bit more complicated than tied arrays but like all tied variables 1 scr .hern H inrhe same way. 1 need ỊO implement methods for all of the actions 1 want my tied hashto handle. Table 17-2 shows some of the hash operations and their cor-respondmbhodrnnthodS Table 17-2. Tht mappibgofut e sahts w acf. Obit 0smethoes Action dast 016 0 Itomethod Set value h str val STORE str val Get value val r str FET H s r Delete a key delete h str DELETE str Check for a key exists h str EXISTS str s Next key each h NEXTKEY s-tr s Clear the hash h k 0 CLEAR str One common task at leastforme is to afnumulateacount of something in a hash. One of my favorite exampfef to show in Perkcouteesis a word frequency counter. By the time students get to the third day of the Learning Perl course they know enough to write a simple word counter g my hasH

TỪ KHÓA LIÊN QUAN