[pm-h] Interesting Blog Posts on Context & Array vs List

Uri Guttman uri at stemsystems.com
Wed Feb 19 21:11:03 PST 2014


On 02/19/2014 02:33 PM, Mark Allen wrote:
> I pitched a book called Perl for Python Programmers[0] and it included an entire chapter about how important context is when understanding Perl.
>
> So there's the *number* contexts: void, scalar, list
> And there's the *type* contexts: number, string, references

there is also integer context provided by indexing and various builtins 
that have index or length args (substr, splice, etc). this is why you 
can do the great pick a random element from an array like this:

	my $rand_val = $array[rand @array] ;

no need for an int() there as indexing is an integer context.

there is also boolean context.

the Want.pm module has access to even more contexts like ASSIGN and 
howmany().

thanx,

uri

-- 
Uri Guttman - The Perl Hunter
The Best Perl Jobs, The Best Perl Hackers
http://PerlHunter.com


More information about the Houston mailing list