For Programmers: Free Programming Magazines  


Home > Archive > PERL Beginners > April 2005 > RE : basic class problem









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author RE : basic class problem
Jose Nyimi

2005-04-24, 3:55 pm



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


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

HTH,
Jos=E9.


Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com