in reply to How to allocate a struct?

Do not be fearful of the monks , they are so amiable
Here is a working copy of your code.
First thing to do is read perldoc Class::Struct
Using an editor with color coding can help u catch trival issues in perl like doc as opposed to $doc.
you will also be greatly benefitted by reading perldoc perlreftut to understand how references work.
coming back to perl after many years, i realise the key to understanding a language is through its basic data structures, so perldoc perldata / perldsc and perlvar are your manual until you reach the level of proficiency
package TestPackage; 2 use strict; 3 use warnings; 4 use Class::Struct; # include <structs> 5 6 struct( document => { 7 fileID => '$', # $ = scalar = int 8 filename => '@', # @ = array (of char) = string 9 tags => '@' # tags - array of strings 10 }); 11 12 # all of these three attempts to allocate memory fail: 13 #my $doc = document->new( ); # produces: Can't locate object m +ethod "fileID" via package "doc" (perhaps you forgot to load "doc"?) +at testsnippet01. pl line 18. 14 #my $doc = new( 'document'); # produces: Undefined subroutine +&main::new called at testsnippet01.pl line 12. 15 #my $doc = new( document); # produces: Bareword "document" n +ot allowed while "strict subs" in use at testsnippet01.pl line 13. 16 17 my $doc = new document; # Hopefully a Perl saint knows what + goes here... 18 19 $doc->fileID( 123 ); 20 $doc->filename( ['SampleFileName'] ); 21 $doc->tags( ['tag1', 'tag2', 'tag3'] ); 22 23 print "File ID: ", $doc->fileID, "\n"; 24 print "Filename: ", $doc->filename->[0], "\n"; 25 print "Tags: ", $doc->tags->[0], "\n";
Do not wait to strike when the iron is hot! Make it hot by striking - WB Yeats