in reply to Re: Re: Scalars, Lists, and Arrays
in thread Scalars, Lists, and Arrays
There are other contexts as well. Camel III lists three of them. They are:
-
Boolean context, such as when we test for the existence of values in an array. while (@files) { my $file = shift @files; unlink $file or warn "Can't delete $file: $!\n; }
- Void context. It is unclear from Camel III what this context does. The example Camel III gives is a statement consisting of the quoted string "Camel Lot"; Apparently the -w option on the perl interpreter does not like this context, and returns a warning on it. Maybe it's best to avoid this one altogether.
- Interpolative context, which occurs inside quoted strings when one includes a variable name. The substitution operator s/// and some other expressions also occur in interpolative context.
Boolean context is ubiquitous, so let's give this little brother of list and scalar its due!
In Section
Seekers of Perl Wisdom