The reasons: -I'm writing a class and try to respect as much as possible OOP concept. -So I would like to use a logfile handle as "class attribute" ( not an object attribute) that will be used by a debugger methode of my class. -I wrote something like: #!/usr/bin/perl -w package A; use strict; { #Encapsulated class data my $_default_atrr_href=&_init(); my %_atrr_data=# DEFAULT ACCESSIBILITY ( _LOG => [$$_default_atrr_href{_LOG} , 'read' ], _ID => [undef , 'read/write'], ); #Here, class methodes to operate on encapsulated class data } sub _init{ my $_attr_href=&_parse_conf_file(); #Extend attributes $$_attr_href{_LOG}=&_get_file_handle($ENV{APP_DIR}."/DEBUG.log"); #here why I need my sub _get_file_handle !!!! } sub _get_file_handle { #I will put here what I suggested me #Thanks ... #Is this a correct Design ? } #Of course there is code below: constructor and bla bla ... .... .... .... 1; ### José. Peter Scott <[EMAIL PROTECTED]> a écrit : At 02:29 AM 5/20/02 +0200, José Nyimi wrote:
>Hello, > >For some reasons, I would to write a sub that return an handle of a given >file : Knowing the reasons would be heplful. It may be the wrong solution >$LOG=get_file_handle($file_name); > >So afterward I could say print $LOG "bla bla"; >[snip]But I don't see how can I keep it work whitout using typeglob >(*LOG{IO}). > >Do you have an other way to do it ? sub get_file_handle { my $fh; open $fh, '>'.shift and return $fh } -- Peter Scott Pacific Systems Design Technologies http://www.perldebugged.com --------------------------------- Yahoo! Mail -- Une adresse @yahoo.fr gratuite et en français !