use strict; use warnings; use Class::Struct; # include struct( document => { fileID => '$', # $ = scalar = int filename => '@', # @ = array (of char) = string tags => '@' # tags - array of strings }); # all of these three attempts to allocate memory fail: #my $doc = document->new( ); # produces: Can't locate object method "fileID" via package "doc" (perhaps you forgot to load "doc"?) at testsnippet01.pl line 18. #my $doc = new( 'document'); # produces: Undefined subroutine &main::new called at testsnippet01.pl line 12. #my $doc = new( document); # produces: Bareword "document" not allowed while "strict subs" in use at testsnippet01.pl line 13. my $doc = # Hopefully a Perl saint knows what goes here... doc->fileID( 123 ); doc->filename( 'SampleFileName' ); doc->tags( 'tag1', 'tag2', 'tag3' ); print "File ID: ", doc->fileID, "\n"; print "Filename: ", doc->filename, "\n"; print "Tags: ", doc->tags, "\n";