February 2012
Intermediate to advanced
1184 pages
37h 17m
English
Another peculiar kind of scalar context is void context. This context not only doesn’t care what the return value’s type is, it doesn’t even want a return value. From the standpoint of how functions work, it’s no different from an ordinary scalar context. But if you have warnings enabled, the Perl compiler will warn you if you use an expression with no side effects in a place that doesn’t want a value, such as in a statement that doesn’t return a value. For example, if you use a string as a statement:
"Camel Lot";
you may get a warning like this:
Useless use of a constant in void context in myprog line 123;
Read now
Unlock full access