Is there a perl equivalent to the following....

Is there a perl equivalent to the following....

am 24.08.2007 03:06:45 von grocery_stocker

Is there a perl equivalent to the java 'this' keyword ?

Chad

Re: Is there a perl equivalent to the following....

am 24.08.2007 03:32:25 von merlyn

>>>>> "grocery" == grocery stocker writes:

grocery> Is there a perl equivalent to the java 'this' keyword ?

In a Perl object call, that's the first parameter to the subroutine.

sub some_method {
my $this = shift;
...
$this->some_other_method
...
}

Of course, you can call it $self or $this or $xyzzy if you want.

print "Just another Perl hacker,"; # the original

--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095

Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!

--
Posted via a free Usenet account from http://www.teranews.com

Re: Is there a perl equivalent to the following....

am 24.08.2007 03:59:31 von Sherm Pendley

grocery_stocker writes:

> Is there a perl equivalent to the java 'this' keyword ?

Sort of. "This" is passed to methods, but it's just the first argument,
not a keyword:

sub foo {
my ($this, $that, $the_other) = @_;
}

Perl has *many* very good tutorials about OOP in Perl. You really should
read them. From "perldoc perl":

perlboot Perl OO tutorial for beginners
perltoot Perl OO tutorial, part 1
perltooc Perl OO tutorial, part 2
perlbot Perl OO tricks and examples

sherm--

--
Web Hosting by West Virginians, for West Virginians: http://wv-www.net
Cocoa programming in Perl: http://camelbones.sourceforge.net