Hi there, welcome to the monastery!
Couple little typos in your code that you can see below. The main one is that you forgot the $ sigil on the doc-> in the print statements:
use Class::Struct; struct Document => { fileid => '$', filename => '@', tags => '@' }; my $doc = Document->new( fileid => 2, filename => [qw(a b c)], tags => [qw(d e f)] ); print "File ID: ", $doc->fileid, "\n"; print "Filename: ", @{$doc->filename}, "\n"; print "Tags: ", @{$doc->tags}, "\n";
Having looked at Class::Struct a bit, I can't say there is much here to recommend it anymore. A more current recommendation would be to use Moo (or Moose) for these features and more. Here is a posting from quite some time back from a more seasoned monk with a comparison.
In reply to Re: How to allocate a struct?
by Loops
in thread How to allocate a struct?
by dissident
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |