Re: Splitting and comparing file names
- From: "Paul Lalli" <mritty@xxxxxxxxx>
- Date: 14 Dec 2006 09:44:32 -0800
boyd wrote:
my $avg = sum(@times) / (scalar @times); # @times would work,
# but scalar guarantees the number of elements.
The division operator "guarantees" the number of elements just as much
as the scalar keyword does. I don't have an issue with your use of
scalar if it helps you read the code more clearly, but the comment is
misleading at best.
The scalar keyword is only relevant where the array would otherwise be
evaluated in list context. The division operator (as well as all the
other arithmetic operators) impose scalar context all on their own,
always, and un-ambiguously.
Paul Lalli
.
- References:
- Splitting and comparing file names
- From: Jake
- Re: Splitting and comparing file names
- From: boyd
- Splitting and comparing file names
- Prev by Date: Re: Splitting and comparing file names
- Next by Date: Re: List all modules installed
- Previous by thread: Re: Splitting and comparing file names
- Next by thread: Re: Splitting and comparing file names
- Index(es):