You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Wang, , 上海, , wx...@marsec.net on 2001/06/06 06:09:40 UTC

答复: ′e?′: In module require configuration file [frig]

TKS,
Why use Data::Dumper ?

> -----原始邮件-----
> 发件人: Jamie LeTual [mailto:jamie@hbesoftware.com]
> 发送时间: 2001年6月6日 11:53
> 收件人: Wang Xingyu íõÐËóî [éϺ£]; modperl@apache.org
> 主题: Re: ′e?′: In module require configuration file [frig]
> 
> 
> typos, sorry. Damned cut and paste
> 
> Jamie LeTual wrote:
>  > 
>  > How about this:
>  > 
>  > #======= mymodule.pm =========
>  > package mymodule;
>  > use strict;
>  > 
>  > sub new
>  > {
>  >         my $type = shift;
>  >         my $conf  = shift;
>  > 
>  >         my $self = { conf => require $conf };
>  >         bless $self, $type;
>  > 
>  >         return $self;
>  > }
>  > 
>  > 1;
>  > #======= conf.pl =========
>  > { web_name => 'foo.com' };
>  > 
> -> #======= conf.pm =========
> +> #======= somefile.pl =========
>  > #!/usr/bin/perl
>  > use strict;
>  > use Data::Dumper;
>  > use mymodule;
>  > 
> -> my $m = mymodule->new('conf.pm');
> +> my $m = mymodule->new('conf.pl');
>  > print Dumper($m);
>  > 
> 
> ...
> 
> -- 
> -[sent from home]-----------------------------------------------
> | Jamie LeTual             |Email : jamie@mail.letual.net       |
> | Programmeur Errant       |Phone : (514) 523-0940              |
> |                          |PGP   : http://people.hbe.ca/~jamie |
> |__________________________|____________________________________|
> 

Re: ??: ?e??: In module require configuration file [frig]

Posted by Jamie LeTual <ja...@hbesoftware.com>.
Wang Xingyu ??? [??] wrote:
> 
> TKS,
> Why use Data::Dumper ?
> 

It was just for the example, when you run it, it spits out:
$VAR1 = bless( {
                 'conf' => {
                             'web_name' => 'foo.com'
                           }
               }, 'mymodule' );

showing that 'conf' is available through the object, as in
$m->{conf}->{web_name}