The Wayback Machine - https://web.archive.org/web/20160131071420/http://perldoc.perl.org:80/functions/scalar.html

Perl version

Modules

  • ABCDE
  • FGHIL
  • MNOPS
  • TUX

scalar

Perl 5 version 22.0 documentation

Please note: Many features of this site require JavaScript. You appear to have JavaScript disabled, or are running a non-JavaScript capable web browser.

To get the best experience, please enable JavaScript or download a modern web browser such as Internet Explorer 8, Firefox, Safari, or Google Chrome.

Recently read

scalar

  • scalar EXPR

    Forces EXPR to be interpreted in scalar context and returns the value of EXPR.

    1. @counts = ( scalar @a, scalar @b, scalar @c );

    There is no equivalent operator to force an expression to be interpolated in list context because in practice, this is never needed. If you really wanted to do so, however, you could use the construction @{[ (some expression) ]} , but usually a simple (some expression) suffices.

    Because scalar is a unary operator, if you accidentally use a parenthesized list for the EXPR, this behaves as a scalar comma expression, evaluating all but the last element in void context and returning the final element evaluated in scalar context. This is seldom what you want.

    The following single statement:

    1. print uc(scalar(&foo,$bar)),$baz;

    is the moral equivalent of these two:

    1. &foo;
    2. print(uc($bar),$baz);

    See perlop for more details on unary operators and the comma operator.

 
Morty Proxy This is a proxified and sanitized view of the page, visit original site.