mutagen has asked for the wisdom of the Perl Monks concerning the following question:
OK, great. but I don't want to make new DocumentInfo objects directly. I have a DocumentManager class that has a method getDocumentInfo, which passes its arguments to the new() method of DocumentInfo, and which I want to return a DocumentInfo object.. Here is that method in DocumentManager:use DocumentInfo; my $doc_info = DocumentInfo::new('919'); my $last_accessed = $doc_info->getLastAccessed();
and here's how I attempt to call it:use DocumentInfo; ... sub getDocumentInfo { my $file_id = shift; # suspect problem here return DocumentInfo::new($file_id); }
It doesn't work because DocumentInfo does not get a scalar '919' as an arg to it's new() method - it gets a hash reference - $doc_id. Is this OO idiom impossible in Perl, or is there some syntax that will work?use DocumentManager; my $doc_mgr = DocumentManager::new(); my $doc_info = $doc_mgr->getDocumentInfo('919');
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: object method that returns object
by japhy (Canon) on Apr 13, 2002 at 01:43 UTC | |
|
Re: object method that returns object
by trs80 (Priest) on Apr 13, 2002 at 01:46 UTC | |
|
Re: object method that returns object
by Fletch (Bishop) on Apr 13, 2002 at 02:02 UTC | |
|
Re: object method that returns object
by thpfft (Chaplain) on Apr 13, 2002 at 02:30 UTC | |
|
Re: object method that returns object
by rinceWind (Monsignor) on Apr 13, 2002 at 10:00 UTC |