# Object Oriented Perl Chap02

This is a note about chap02 in “Object oriented perl”.

1.For a hash, we have two ways to get the key-value pair.

The other way is:

2.Subroutines can also be declared with a prototype, which is a series of specifiers that tells the compiler to restrict the type and number of arguments with which the subroutine may be invoked. For example, in the subroutine definition:

The prototype is () and specifies that the subroutine insensitive_less_than can only be called with exactly two arguments, each of which will be treated as a scalar—even if it’s actually an array!

Prototypes are only enforced when a subroutine is called using the name(args) syntax. Prototypes are not enforced when a subroutine is called with a leading & or through a subroutine reference.

3.Here is a clear illustration of how to use reference in Perl:

4.Here is a script to realize the function of skipping along an array by a fixed step size. It uses anynymous soubroutine and closure.

The sad thing is, I am not sure if this is the best way to achieve the function.