In the sample I provided, this is main:
my %movies_data = (
'Firefly' => {
'title' => 'Firefly',
'startyear' => '2002',
'endyear' => '2003',
'media' => 'tv',
},
'Criminal Minds' => {
'title' => 'Criminal Minds',
'startyear' => '2005',
'endyear' => 'tbd',
'media' => 'tv',
},
'The 10th Kingdom' => {
'title' => 'The 10th Kingdom',
'startyear' => '2000',
'endyear' => '',
'media' => 'miniseries',
},
'Iron Man' => {
'title' => 'Iron Man',
'startyear' => '2008',
'endyear' => '',
'media' => 'film',
'basedon' => 'comics',
'company' => 'Marvel Comics',
},
'Tin Man' => {
'startyear' => '2007',
'title' => 'Tin Man',
'media' => 'miniseries',
'basedon' => 'novel',
'company' => 'L. Frank Baum'
},
'The Avengers (1998)' => {
'title' => 'The Avengers (1998)',
'startyear' => '1998',
'media' => 'film',
'basedon' => 'television series',
'company' => 'Thames Television',
},
);
my $library = library->new(name => "Lucky's");
foreach my $movie (values %movies_data) {
$library->add_movie(movie->new(%$movie));
}
$library->print();
From this, you can see that $movie is a reference to each of the hashes contaning the movie info (startyear, endyear, etc). When I call movie->new(%$movie) it is a call to the new function in the package movie, passing in the de-referenced hash containing the movie information. new is expecting a hash of stuff and deals with it appropriately when it creates the movie object. As for copying it, you don't have to do this - You can store this information in a myriad of ways (I would suggest a read-only XML file that you can easily backup, which your scripts can load easily)