- Perl Basics
- Perl - Home
- Perl - Introduction
- Perl - Environment
- Perl - Syntax Overview
- Perl - Data Types
- Perl - Variables
- Perl - Scalars
- Perl - Arrays
- Perl - Hashes
- Perl - IF...ELSE
- Perl - Loops
- Perl - Operators
- Perl - Date & Time
- Perl - Subroutines
- Perl - References
- Perl - Formats
- Perl - File I/O
- Perl - Directories
- Perl - Error Handling
- Perl - Special Variables
- Perl - Coding Standard
- Perl - Regular Expressions
- Perl - Sending Email
- Perl Advanced
- Perl - Socket Programming
- Perl - Object Oriented
- Perl - Database Access
- Perl - CGI Programming
- Perl - Packages & Modules
- Perl - Process Management
- Perl - Embedded Documentation
- Perl - Functions References
- Perl Useful Resources
- Perl - Questions and Answers
- Perl - Quick Guide
- Perl - Useful Resources
- Perl - Discussion
Perl sub Function
Description
This function defines a new subroutine. The arguments shown above follow these rules −
NAME is the name of the subroutine. Named subroutines can be predeclared (without an associated code block) with, or without, prototype specifications.
Anonymous subroutines must have a definition.
PROTO defines the prototype for a function, which will be used when the function is called to validate the supplied arguments.
ATTRS define additional information for the parser about the subroutine being declared.
Syntax
Following is the simple syntax for this function −
sub NAME PROTO ATTRS BLOCK# Named, prototype, attributes, definition sub NAME ATTRS BLOCK # Named, attributes, definition sub NAME PROTO BLOCK # Named, prototype, definition sub NAME BLOCK # Named, definition sub NAME PROTO ATTRS # Named, prototype, attributes sub NAME ATTRS # Named, attributes sub NAME PROTO # Named, prototype sub NAME # Named sub PROTO ATTRS BLOCK # Anonymous, prototype, attributes, definition sub ATTRS BLOCK # Anonymous, attributes, definition sub PROTO BLOCK # Anonymous, prototype, definition sub BLOCK # Anonymous, definition
Return Value
This function does not return any value.
perl_function_references.htm
Advertisements