> -----Message d'origine-----
> De : Graeme McLaren [mailto:[EMAIL PROTECTED] 
> Envoyé : dimanche 24 avril 2005 19:01
> À : beginners@perl.org
> Objet : basic class problem
> 
> 
> Hi all I'm trying to write a basic class that will contain some 
> configuration details, unfortunately it bombs out and doesn't 
> do anything.
> 
> ################### start of class 
> ########################### #configuration.pm package 
> configuration; use strict;
> 
> 
> sub new{
>     my $class=shift;
>     my $self=shift;
> 
>     bless($self, $class);
>     return $self;
> }
> 
> sub get_conf{
>     my $self=shift;
>     my %conf=(
>               db_name="bla1",
>             username="bla2",
>             password="bla3"
> 
>     );
> 
> return \%conf;
> 
> }
> 
> 1;
> ################ end of class ####################
> 
> 
> Mt CGI script is this:
> 
> ##################### CGI Script ####################### 
> #!/usr/bin/perl -w use strict; use configuration;
> 
> print "Content-type: text/html\n\n";
> 
> my $conf=configuration->new;
> my $conf->get_conf;
> 
> print "$conf->{'db_name'}"; 

my $obj=configuration->new;
my $conf=$obj->get_conf; 
print $conf->{'db_name'};#perldoc Data::Dumper BTW

HTH,
José.



--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to