- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Subroutine Call Context in Perl
The context of a Perl subroutine or statement is defined as the type of return value that is expected. This allows you to use a single function that returns different values based on what the user is expecting to receive. For example, the following localtime() returns a string when it is called in scalar context, but it returns a list when it is called in list context.
my $datestring = localtime( time );
In this example, the value of $timestr is now a string made up of the current date and time, for example, Thu Nov 30 15:21:33 2000. Conversely −
($sec,$min,$hour,$mday,$mon, $year,$wday,$yday,$isdst) = localtime(time);
Now the individual variables contain the corresponding values returned by localtime() subroutine.
- Related Articles
- Define and Call a Subroutine in Perl
- Private Variables in a Subroutine in Perl
- Passing Arguments to a Subroutine in Perl
- Returning Value from a Subroutine in Perl
- Perl Variable Context
- Context api in React.js
- Context API in ReactJS
- CURL context options in PHP
- Meditation in the Indian Context
- Monitoring context switches in Linux
- Comments in Perl
- Whitespaces in Perl
- Dereferencing in Perl
- PHP Context Parameters
- Python Context Variables

Advertisements