in reply to Strings & Scalar Context

Try inserting this at the top of your code.

use strict;

It will catch barewords like these and a host of other gotchas.

Update: Added requested explanation of why/how atoi.

strict is your good friend who will keep you out of a lot of trouble.

atoi is the C language function ascii to integer which perl uses internally to convert strings to numbers.

You had a - in your code so Perl converted both arguments to numbers (hence the atoi) and then subtracted them and saved the result in $foo.

Hope that makes it clearer.

Replies are listed 'Best First'.
Re: Re: Strings & Scalar Context
by crazysniffable (Acolyte) on Sep 08, 2001 at 01:06 UTC
    Thanks for the tip. I understand the bareword issue. What I (didn't know I) was looking for was the atoi explanation.