use strict; my $p = Foo->new(); $p->bkg_img("whatever"); $p->print_html; package Foo; sub new { my $class = shift; my $self = {}; $self->{BKG_IMAGE} = "image"; bless($self, $class); return $self; } sub bkg_img { my $self = shift; $self->{BKG_IMAGE} = $_[0]; } sub print_html { my $self = shift; print <<"HTML"; $self->{BKG_IMAGE} HTML }