# nh 30.12.2001 foo 2. SCALAR DATA I. What? A. Anything -- numbers (integers, double, *and* float), strings B. Numbers i. all numbers have same internal format ii. if you need precision you can use Math::BigInt or Math::BigFloat iii. can specify integer, positive or negative, with decimal points, or with e notation a. 3 b. 3.14159 c. 3e-10 d. -3e-10 C. Strings (sequences of characters) i. taken from entire 256 ch set (no exceptions for ü, &c.) ii. 'single-quoted' a. everything legal, b. except \' (escape the single quote), and c. \\ (escape a backslash) d. '\n' renders as \n, not as a newline iii. "double-quoted" a. control characters can be specified: "\n" = newline; &c. b. also ascii, hex, and octal. II. Operators A. Numerical i. +, -, *, /, ** (exponent), % (mod) ii. comparisons: < <= == >= > != B. Strings i. concatenate with "." operator ii. different comparison operators: eq (==), ne (!=), lt (<), gt (>), le (<=), ge (>=) -- OPPOSITE of UNIX shell programming iii. different for strings because while 7 < 30, "7" > "30" (ascii "3" is less than ascii "7" iv. repitition: '"fred" x 3' = "fredfredfred"; '(3+2)x4' = "5555" (*not* commutative -- "4x(3+2)" = "44444") v. if string value used as operand with numeric operator, it will be converted! "123.45fred" => "123.45"; "fred" => 0 -- and vice-versa III. Scalar Operators & functions A. Variables always start with $ i. $a=3 returns 3, so ... ii. $c = 4+($a=3) returns 7 B. Incrementing i. $a = $a + 1 is equivalent to $a += 1; ($b *= 3; &c.) ii. autoincrement & decrement -- $a++ or ++$a -- the first one operates and then increments; the second increments and then operates. --$b or $b-- : same thing C. 'chop' and 'chomp' i. chop ($x); chops off the last letter and returns that ii. chomp ($x) only chops off ending newline ch | `-> abbreviate getting & chomping: chomp($a = ); IV. Variable Interpolation A. $a = "fred"; $b = "some guy $a"; --> $b = "some guy fred" B. $x = '$fred' --> $x = literally $ then 'fred' C. $y = "hey $x" --> $y = "hey fred" D. can delimit varaibles: $x = "${fruit}s are red"; V. really simple I/O A. i. everything up to a newline character ii. chomp it off all in one fell swoop with : chomp($a = ); B. Output i. use print -- with or without (s); usually with "s" VI. if you fuck up ... A. if you try and use an undefined variable, you'll get an 'undef' error.