Re: accessing object variables from callback function
- From: "Dr.Ruud" <rvtol+news@xxxxxxxxxxxx>
- Date: Fri, 30 Jun 2006 09:24:11 +0200
kaisung@xxxxxxxxx schreef:
package MyTest;
Missing:
use strict ;
use warnings ;
use XML::Parser;
# Create a new object
sub new { [...]
}
# Load an xml file and count the number of tags
sub load { [...]
}
# Return the number of tags in loaded xml file
sub numTags { [...]
}
[...]
1;
-----END MyTest.pm-----
-----BEGIN mytest.pl-----
#!/usr/bin/perl -w
Missing:
use strict ;
If your perl is not very old, replace the -w (in the shebang) by the
lexical
use warnings ;
use MyTest;
my $test = MyTest->new();
Variant:
my $test = new MyTest ;
$test->load("test.html");
print "numTags = " . $test->numTags() . "\n";
Variant:
$test->load('test.html') ;
print "numTags = @{[ $test->numTags() ]}\n" ;
or even:
print "numTags = $test->{numTags}\n" ;
(which bypasses the method)
--
Affijn, Ruud
"Gewoon is een tijger."
.
- Follow-Ups:
- Re: accessing object variables from callback function
- From: Brian McCauley
- Re: accessing object variables from callback function
- References:
- accessing object variables from callback function
- From: kaisung@xxxxxxxxx
- Re: accessing object variables from callback function
- From: anno4000
- Re: accessing object variables from callback function
- From: Brian McCauley
- Re: accessing object variables from callback function
- From: kaisung@xxxxxxxxx
- accessing object variables from callback function
- Prev by Date: Re: stuck in a while loop
- Next by Date: Re: Professional IDE for a cross-platform Perl application
- Previous by thread: Re: accessing object variables from callback function
- Next by thread: Re: accessing object variables from callback function
- Index(es):
Relevant Pages
|