The term 'attribute' is a bit ambiguous when it comes to Perl;
Perl5 usually uses this term for something a bit different.
I'm assuming you're referring to some variables of which there is only one
instance per class, and you want some class methods to get and set them.
In which case, something like this:
package First;
my ($attr1, @attr2, ...);
sub get_attr1 { $attr1 }
sub set_attr1 { my $class = shift; $attr = shift }
sub get_attr2 { @attr2 }
sub set_attr2 { my $class = shift; @attr2 = @_ }
Of course there are many ways of doing this; the above is just one example.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.