Sometimes you just have to peek. Whether it's baking brownies, an overheated engine, or a data structure, sometimes you just have to look under the hood. When programming in perl you need to dump the contents of your data structure to see what's there.

PERL:
  1. #!/usr/bin/perl
  2.  
  3. use strict;
  4. use warnings;
  5. use Data::Dumper 'Dumper';
  6.  
  7. my @sirsi_array = (
  8.     '671|Psychophysiology|PPSY',
  9.     '671|Psychophysiology|http://www.blackwell-synergy.com/servlet/useragent?func=showIssues&code=psyp',
  10.     '675|Notes and queries|PENG',
  11.     '675|Notes and queries|http://www.bodley.ox.ac.uk/ilej/journals',
  12.     '675|Notes and queries|http://www.ingenta.com/journals/browse/oup/notesj',
  13.     '676|The Journal of general psychology|http://asa.lib.lehigh.edu/cgi-bin/pubid?Pub=14345',
  14.     '681|Greece & Rome|PHIS',
  15.     '681|Greece & Rome|http://www.jstor.org/journals/00173835.html',
  16.     '681|Greece & Rome|http://www3.oup.co.uk/gromej/contents.html',
  17. );
  18.  
  19. my %sirsi;
  20. foreach my $item ( @sirsi_array ) {
  21.     my( $key, $title, $data ) = split /|/, $item;
  22.     push @{ $sirsi{ $key } }, [ $key, $title, ];
  23. }
  24.  
  25. print Dumper \%sirsi;
  26.  
  27. __END__

Next time you find yourself scratching your head when dealing with a complex data structure, dump it.

PERL:
  1. $VAR1 = {
  2.           '675' => [
  3.                      [
  4.                        '675',
  5.                        'Notes and queries'
  6.                      ],
  7.                      [
  8.                        '675',
  9.                        'Notes and queries'
  10.                      ],
  11.                      [
  12.                        '675',
  13.                        'Notes and queries'
  14.                      ]
  15.                    ],
  16.           '676' => [
  17.                      [
  18.                        '676',
  19.                        'The Journal of general psychology'
  20.                      ]
  21.                    ],
  22.           '671' => [
  23.                      [
  24.                        '671',
  25.                        'Psychophysiology'
  26.                      ],
  27.                      [
  28.                        '671',
  29.                        'Psychophysiology'
  30.                      ]
  31.                    ],
  32.           '681' => [
  33.                      [
  34.                        '681',
  35.                        'Greece & Rome'
  36.                      ],
  37.                      [
  38.                        '681',
  39.                        'Greece & Rome'
  40.                      ],
  41.                      [
  42.                        '681',
  43.                        'Greece & Rome'
  44.                      ]
  45.                    ]
  46.         };