VOOZH about

URL: https://www.geeksforgeeks.org/perl/perl-scalar-keyword/

⇱ Perl | scalar keyword - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Perl | scalar keyword

Last Updated : 11 Jul, 2025

scalar keyword in Perl is used to convert the expression to scalar context. This is a forceful evaluation of expression to scalar context even if it works well in list context.
 

Syntax: scalar expr
Returns: a scalar value


Example 1: 
 


Output: 
Array in List form: Geeks For Geeks 1 1 0 0 9 6
Array in scalar form: 3 6

 

Example 2: 
 


Output: 
Concatenation of Arrays: Welcome To Geeks 1 1 0 0 9 6
Difference in number of elements: 3

 
Comment
Article Tags:

Explore