OOP

John Evans jtevans at kilnar.com
Mon Sep 30 17:41:33 CDT 2002


I'm doing pretty good at OO Perl, but I would like to know if there is a
way to create an package, OOP it, and use it all in a single file. I'm
trying to write a small script that would be very easy to OOP, but I don't
want to have to manage two seperate files (just in case they get
serparated and the whole thing falls apart.)


At the moment, I have been doing something like:

FILE: Lookup.pm
=============
package Lookup;

sub new {
# blah blah blah
}

sub find_user {
# blah blah blah
}


FILE: finduser.pl
====================
use Lookup;

$users{"Joe"} = Lookup->new(183);
$users{"Bob"} = Lookup->new(184);

foreach $user (sort keys $users) {
  $users{$user}->find_user();
}


Basically, I'm trying to combine Lookup.pm into finduser.pl so that I just
have a single file.

What's the trick to get it done?

Thanks!

-- 
John Evans
http://jtevans.kilnar.com/




More information about the Pikes-peak-pm mailing list