On Mon, 22 Oct 2001 12:18:16 -0400
Aaron Sherman <[EMAIL PROTECTED]> wrote:
> > > $z[0] = 50;
> > > $z[2] = 20;
> > > @x = @y[@z];
> > In your code, should @x contain (@y[50,0,20]) or (@y[50,20]) or
> > (@y[50,undef,20]) ?
> @y[50,undef,20], which in Perl5 is @y[50,0,20].
An arbitrary and perhaps confusing decision.
> If there are other means, I'm not thinking of them right now.
> Perl's conversion of undefined values and strings to 0 is VERY
> USEFUL. I'd really like to avoid breaking it. Yes //, makes it
> easier to get over the undef thing, but only a little.
I'm always getting warnings when I do stuff like that in my code.
> Let's take this code as an example:
> while(<>) {
> $count++;
> $total += substr($_,22,2);
> }
> printf "Average: %.2f\n", $total/$count;
An interesting example. The answer I have in mind:
if (m/^.{21}(\d\d)/) {
$total += $1;
}
> More, someone has mentioned the %x{$_}++ feature, which IMHO, MUST
> continue to work.
What is void plus one?
I think a pragma for this would be ideal.
Sam.