Page 196 -
P. 196

hashes and databases






                Here‛s one surfer‛s data from the file, assigned to a variable called line:


                                line = "101;Johnny 'wave-boy' Jones;USA;8.32;Fish;21"

                Grab your pencil and write some code to process this line and display it on screen like this:


                                ID:         101
                                Name:       Johnny 'wave-boy' Jones
                                Country:    USA
                                Average:    8.32
                                Board type: Fish
                                Age:        21

                 Hints: If you pass a string parameter to the split() method, the data is cut where the string parameter
                 occurs, as opposed to the cut occurring at a space character (which is split()'s default behavior). Also,
                 consider using multiple-assignment on the left side of the assignment operator when assigning more than one
                 name-value pairing to a hash.






































                                                                                       you are here 4    161
   191   192   193   194   195   196   197   198   199   200   201