Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

creating module as OO design, what's required

Status
Not open for further replies.

1DMF

Programmer
Jan 18, 2005
8,795
0
0
GB
Hi,

I'm about to embark on my first Object Orientated module for a web application, I was wondering if, as it is a module, I am still required to use 'BEGIN' as well as the exporter method?

Or can I simply code it with a constuctor , which blesses the variable and then use it in my application.

At little guidance is appreciated.

Thanks,
1DMF



"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!"

Google Rank Extractor -> Perl beta with FusionCharts
 
It's ok , I sussed it out...
Code:
######################
# Set Error Trapping #
######################

use CGI::Carp qw/fatalsToBrowser warningsToBrowser/;
use warnings;
use strict;

##########################
# Set Package Name Space #
##########################
package CaseChecker;

##########################
# Public Class Variables #
##########################
our $VERSION = '0.01';

###########################
# Private Class Variables #
###########################
my $now = time();

##########################
# Class Contrcutor New() #
##########################
sub new {
    
    # class variable
    my $class = shift;

    # class attributes
    my $self = {
       
        REASON  => undef,
        CHECK_TYPE => undef,
        @_,

    };
     
    # Bless the data structure, making it a true object
    bless ($self,$class);

    # Return the object to the calling program.
    return $self;
}

What I couldn't get my head round was why in my sub routines the vars were blank, but once I realised you have to use
Code:
 my $self = shift;
at the top of each sub routine it's all working fine.

If you have any heads up though, I'd still apreciate the input.

Regards,
1DMF.

"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!"

Google Rank Extractor -> Perl beta with FusionCharts
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top