[oak perl] Lexical vs. Package variables
Belden Lyman
blyman at iii.com
Wed Feb 9 13:47:44 PST 2005
On Wed, 2005-02-09 at 13:13, Sandy Santra wrote:
> More complicated, yes. But I need to be able to enlarge my thinking so I
> can grasp more complicated programming models. I can't believe I'm still
> having a hard time "getting" object-oriented programming. So many people
> are programming Java!
Be fair to yourself.
If you haven't come from a CS background and are trying to teach yourself
about objects, you'll need some time. I'm speaking from experience.
In my experience, objects aren't a hard subject to understand; there's a
mental trick that you need to learn.
Part of getting the trick is to read the right things. perlobj,
perltoot, and perltooc were the only things I knew about when
trying to understand objects. They all went over my head, and each
time I set out on the "I'm gonna learn objects today" trip, I quit
reading them because they're so dense.
Pity, since the very end of perltoot says:
perlboot is a kinder, gentler introduction to object-oriented
programming.
perlboot made things click for me. Give it a try. Work through
the examples. Play with your own changes.
You should also learn about references, particularly what this
stuff does:
my %hash = ( foo => 1, bar => 2 );
my $href = \%hash;
print $href->{foo}, "\n" ;
When you get to be writing your own perl objects, you'll be using
the arrow operator (->) a lot.
Belden
More information about the Oakland
mailing list