Whilst it is perfectly valid to bless something into a package in a subroutine in another package, for future maintenance purposes you might want to abstract this further so that the ABC::Data object is actually being created in its own constructor:
You probably would want to have more logic in ABC::Data::new() to check you really have got the right type of reference and so forth, but the advantage of doing this is that if at some point in the future you need to do some further processing on the data that is peculiar to the ABC::Data 'class' then you can stick it in the constructor without troubling the code that reads the file etc.package ABC; sub readdatafile { my ( $filename) = @_; # get the data into array as required return ABC::Data->new(\@data); } package ABC::Data; sub new { my ( $class, $ref) = @_; return bless $ref, $class; }
/J\
In reply to Re: Returning module pointer
by gellyfish
in thread Returning module pointer
by yazzle
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |