Perl Programming Perl: Bon Voyage Lists and Hashes |
In our previous article we created a “database” of a bookshelf with some books on it. We then learned how to add rows to it, add a single column, and automate a process to add columns to every row. Here, we will continue working with the @Bookshelf “database.” Just so you don't have to go seeking out our previous article, here is the list of fields:
And the code to create the two-dimensional list: #!/usr/bin/perl @Bookshelf = ( [" # ", " Author ", " Title ", " Genre "," Rating "," Location " ], [' 1 ', ' Stephen King ', ' It ', ' Horror ', ' 5 ', ' Top '], [' 2 ', ' Clive Barker ', ' Imajica ', ' Horror ', ' 5 ', ' Top '], [' 3 ', ' Neil Gaiman ', ' American Gods ', ' Dark Fantasy ',' 5 ', ' Top '], [' 4 ', ' Dean Koontz ', ' Tick-Tock ', ' Horror ', ' 1 ', ' GarbageCan '], [' 5 ', ' Charles Bukowski ', ' Letters from a Dirty Old Man ', ' Literature ', ' 5 ', ' Top '], [' 6 ', ' Chuck Pahluniak ', ' Fight Club ', ' Dark Fantasy ', ' 5 ', ' Middle '] );
blog comments powered by Disqus |