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

$_ aliasing

Thread Next
From:
Uri Guttman
Date:
April 3, 2002 00:57
Subject:
$_ aliasing
Message ID:
200204030856.DAA20347@home.sysarch.com.

from exegesis 4:

	In Perl 6, the current topic -- whatever its name and however
	you make it the topic -- is always aliased to $_.

and one of the examples is:


	for @list -> $next {	# iterate @list, aliasing each element to 
				# $next (and to $_)
		print if length > 10;
				# same as: print $next if length $next > 10
		%count{$next}++;
	}

but what if there are multiple bound variables like this example:


	for %phonebook.kv -> $name, $number {
		print "$name: $number\n"
	}

is $_ aliased to either/both/neither of the two topics? are those now
not topics but just aliased variables?

i must know the answer so i don't get drawn to the dark side of the source

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  -------- http://www.stemsystems.com
-- Stem is an Open Source Network Development Toolkit and Application Suite -
----- Stem and Perl Development, Systems Architecture, Design and Coding ----
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org

Thread Next


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