Документация
HTML CSS PHP PERL другое

Hour 8. Functions

 
Previous Table of Contents Next

Hour 8. Functions

What You'll Learn in This Hour:

Almost all computer languages support functions. A function is a grouping of code statements that can be called by name to do some work and then return some value. You've been using functions throughout this book; for example, you've used print, chomp, sort, open, close, split, and so on. These functions are built into Perl.

Perl also allows you to write your own functions. In Perl, user-defined functions are called subroutines, or subs. Like Perl's built-in functions, user-defined functions can take arguments and return values to the caller.

Perl also supports the concept of scope. Scope determines the set of variables that a given statement in the program can access as it is executed. Because of Perl's scope features, you can write functions that can behave autonomously from the rest of your program. Well-written functions can be reused in other programs.

    Previous Table of Contents Next
    © 2000- NIV