Wed 6 Sep 2006
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:
-
#!/usr/bin/perl
-
-
use strict;
-
use warnings;
-
use Data::Dumper 'Dumper';
-
-
my @sirsi_array = (
-
'671|Psychophysiology|PPSY',
-
'671|Psychophysiology|http://www.blackwell-synergy.com/servlet/useragent?func=showIssues&code=psyp',
-
'675|Notes and queries|PENG',
-
'675|Notes and queries|http://www.bodley.ox.ac.uk/ilej/journals',
-
'675|Notes and queries|http://www.ingenta.com/journals/browse/oup/notesj',
-
'676|The Journal of general psychology|http://asa.lib.lehigh.edu/cgi-bin/pubid?Pub=14345',
-
'681|Greece & Rome|PHIS',
-
'681|Greece & Rome|http://www.jstor.org/journals/00173835.html',
-
'681|Greece & Rome|http://www3.oup.co.uk/gromej/contents.html',
-
);
-
-
my %sirsi;
-
foreach my $item ( @sirsi_array ) {
-
}
-
-
print Dumper \%sirsi;
-
-
__END__
Next time you find yourself scratching your head when dealing with a complex data structure, dump it.
PERL:
-
$VAR1 = {
-
'675' => [
-
[
-
'675',
-
'Notes and queries'
-
],
-
[
-
'675',
-
'Notes and queries'
-
],
-
[
-
'675',
-
'Notes and queries'
-
]
-
],
-
'676' => [
-
[
-
'676',
-
'The Journal of general psychology'
-
]
-
],
-
'671' => [
-
[
-
'671',
-
'Psychophysiology'
-
],
-
[
-
'671',
-
'Psychophysiology'
-
]
-
],
-
'681' => [
-
[
-
'681',
-
'Greece & Rome'
-
],
-
[
-
'681',
-
'Greece & Rome'
-
],
-
[
-
'681',
-
'Greece & Rome'
-
]
-
]
-
};
Leave a Reply
You must be logged in to post a comment.