[Bath-pm] OO / global instance variable
Andrew McGregor
andy at pasty.org.uk
Wed May 25 05:42:56 PDT 2005
>> sub handle_char_data {
>> my ($self, $expat, $text); # ******
>>
>> $self->{text} = $text; # ******
>> }
>>
>> sub new {
>> my ($this, %params) = @_;
>> my $class = ref($this) || $this;
>>
>> my $self = {};
>>
>> $self->{parser} = XML::Parser->new ( Handlers => {
>> Char => sub { $self->handle_char_data(@_) }, # ******
>> } );
>>
>> bless $self, $class;
>> return $self;
>> }
>
> How about the above? (altered lines marked *****)
>
Thanks, I tried that to get the same effect sooo many times.
More information about the Bath-pm
mailing list