On Sat, Jun 13, 2009 at 03:48, John W. Krahn<jwkr...@shaw.ca> wrote: > Chas. Owens wrote: >> >> On Fri, Jun 12, 2009 at 20:24, Steve Bertrand<st...@ibctech.ca> wrote: >>> >>> my $hours_used = ($hours_lookup->get_month_hours($dbh, $username, >>> $search_date, 'dialup')); >> >> Why are you creating a list here? Just say > > Do you mean the list ($dbh, $username, $search_date, 'dialup')? I think > that is required for the function to work correctly. Otherwise there is no > other list there, the external parentheses are superfluous and do not define > a list. A scalar rvalue enclosed in parentheses is just a scalar value. snip
No, it is a list of one item, which in scalar context yields the last item (which also happens to be the only item) just like any other list. You are correct that they are superfluous, that is why I am asking him why he is bothering to create the list with them. If the parentheses did not create a list then this code my $undef = (); Would produce an error because there is no scalar value to assign to $undef. Instead, () is a list of no items which yields an undef in scalar context. There is nothing magical about my $scalar = (1); that makes (1) not a list but a scalar instead, it follows the exact same rules as all other lists: yield your last element in scalar context. This is roughly the same as my $s = @a[0]; It works, but is probably not what you meant to say. -- Chas. Owens wonkden.net The most important skill a programmer can have is the ability to read. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/