Hi, I am trying my hand at creating an package and am a bit unsure about some of the inner working of what I've done.
I have a new method sub new { my $class = shift; my $self = {}; $self->{type} = undef; bless($self, $class); return $self; } I also have a 'types' hash which is outside of the new method. Q1) Should I define my types within new and assign the object parameters are creation time? my %_KNOWNTYPES= ( a5 => { root => $root.'/a5', }, a4 => { root => $root.'/a4', }, ); I have created a method to list all the files in a directory like this sub get_file_list { my $self = shift; my $dir = $_KNOWNTYPES{$self->type}->{'root'}; opendir(DIR, $dir) or die "Can't open directory $dir: $!\n"; my @files = grep {/xml/} readdir(DIR); return [EMAIL PROTECTED]; } Then I call it like this my $page = new sendData; $page->type("a5"); my $files = $web->get_file_list; print "files=", join "\n", @{$files},"\n"; It works I'm glad to say but I wasn't clear about a couple of other things. Q2) In get_file_list is the first ARG really $self? I thought it would be the class? However it seems to know about itself. Q3) In new, can I allow for the object create being done with more argument like my $page = new sendData(type => 'a5'). How can you detect named arguments when a object is being created. I hope these are not daft questions. I have been at the Alpaca book and perltoot but the answers didn't jump out at me. Thanx, Dp. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/