1. Object Oriented Perl All you ever wanted to know but were afraid to ask Leonard Miller YAPC::NA 2009 June 23
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
Notas do Editor
My name is Leonard Miller, I am from the University of Minnesota. The point of this talk will be to help you understand what is happening when you See code like this:
First we will setup a scalar, an array and a hash, and then we will use Data::Dumper to print them out.
Here we will make three references to the variables above. This is done with the backslash preceding the sigil.
Here we will make three references to the variables above. This is done with the backslash preceding the sigil.
In perl five the sigil you use tells the compiler what type of variable we are dealing with or accessing. The curly braces give us a different way to access the variable.
This is a side comment about a neat side effect of the curly brace syntax.
This is a neat way that you can call functions in the middle of strings. Although this Is really neat, you shouldn’t use it because it sucks to maintain.
Here we can see the basic de-referencing.
Here is package foo, this is an over simplified version of what is under the hood for Moose. We have a local variable, an init function and an accessor function that sets and retrieves the variable ‘bar’.
Here is package foo, this is an over simplified version of what is under the hood for Moose. We have a local variable, an init function and an accessor function that sets and retrieves the variable ‘bar’.
Bless is what ties an object to a package. The first argument is usually a hashref, but can be any type of reference, and the second is the name of the package. If you have the module loaded, you can create any type of object and perl will not Complain. BEHOLD! THAR BE DRAGONS! You can really muck things up by creating your own objects. Bless only belongs inside a package, never outside.
Bless is what ties an object to a package. The first argument is usually a hashref, but can be any type of reference, and the second is the name of the package. If you have the module loaded, you can create any type of object and perl will not Complain. BEHOLD! THAR BE DRAGONS! You can really muck things up by creating your own objects. Bless only belongs inside a package, never outside.