Google


ADBRITE ads links
You are here: CodeIdol.com > Perl > Intermediate Perl > Subroutine References

SAVE
Digg
Shown on del.icio.us del.icio.us
See Whos Talking About This on Technorati Technorati
I've Reddit reddit

Intermediate Perl



7.1. Referencing a Named Subroutine The Skipper and Gilligan are having a conversation: sub skipper_greets { my $person = shift; print "Skipper: Hey there, $person!\n"; } sub gilligan_greet...



7.2. Anonymous Subroutines In that last example, we never explicitly called subroutines such as professor_greets( ), we only called them indirectly through the coderef. Thus, we wasted some brain cells to come up with a name for the subroutine us...



7.3. Callbacks A subroutine reference is often used for a callback. A callback defines what to do when a subroutine reaches a particular place in an algorithm. For example, the File::Find module exports a find subroutine that can efficiently walk...

read more: Callbacks


7.4. Closures We could also use File::Find to find out some other things about files, such as their size. For the callback's convenience, the current working directory is the item's containing directory, and the item's name wi...

read more: Closures


7.5. Returning a Subroutine from a Subroutine Although a naked block worked nicely to define the callback, having a subroutine return that subroutine reference instead might be more useful: use File::Find; sub create_find_call...



7.6. Closure Variables as Inputs While the previous examples showed closure variables being modified, closure variables are also useful to provide initial or lasting input to the subroutine. For example, let's writ...



7.7. Closure Variables as Static Local Variables A subroutine doesn't have to be an anonymous subroutine to be a closure. If a named subroutine accesses lexical variables, and those variables go out of scope, the named subroutine retains a referen...



7.8. Exercise You can find the answer to this exercise in "Answer for Chapter 7" in the Appendix. 7.8.1. Exercise [50 min] The Professor modified some files on Monday afternoon, and now he's forgotten which ones they were. This happens a...

read more: Exercise

SAVE
Digg
Shown on del.icio.us del.icio.us
See Whos Talking About This on Technorati Technorati
I've Reddit reddit

You are here: CodeIdol.com > Perl > Intermediate Perl > Subroutine References
   
Related tags







Popular Categories
Unix books and guides
AJAX popular information
C# language guides
Windows books and cookbooks
.......






© CodeIdol Labs, 2007