On Sun, Apr 13, 2008 at 12:05 PM, John W. Krahn <[EMAIL PROTECTED]> wrote: snip > > In scalar context it returns true if it matches at all and in list > > context it returns a list of matches. Now, normally a list in scalar > > context returns the last element of the list, > > > > That is the comma operator that does that. There are no commas in (). snip
I think you are splitting hairs (a list is a series of zero or more items separated by commas). You can see that the following function returns a list (the comma operators have already executed to build the list), but when it is evaluated in a scalar context it returns the last item and when evaluated in list then scalar contexts it is the number of items in the list. Also note that when evaluated in list then list context it produces what you would naively think it should (i.e. an empty list). #!/usr/bin/perl use strict; use warnings; sub list { return "a", "b", "c" } my $scalar = list(); my @list = list(); my $list_then_scalar = () = list(); my @list_then_list = () = list(); print "scalar $scalar\n", "list @list\n", "list then scalar $list_then_scalar\n", "list then list @list_then_list\n"; -- Chas. Owens wonkden.net The most important skill a programmer can have is the ability to read. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/