develooper Front page | perl.perl6.language | Postings from September 2002

Re: Regex query

From:
John Williams
Date:
September 20, 2002 20:47
Subject:
Re: Regex query
Message ID:
Pine.LNX.4.33.0209202127470.5163-100000@sharkey.morinda.com
On Fri, 20 Sep 2002, Jonathan Scott Duff wrote:
> > But I cannot tell whether (7) is list context or numeric context,
>
> Nope, you can't tell without the surrounding context:
>
> 	(7) + 0;	# numeric
> 	$a = (7);	# list
> 	(7) == 1;	# boolean (same as (7).length == 1)

No, that last one is clearly numeric context.  == operates on numbers and
returns boolean.  I can't tell whether (7).length is asking for the length
of 7 or the length of a list, but I would be badly surprised if
(3+4).pow(2) returned 1 instead of 49.

~ John Williams




nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About