On Sat, Sep 12, 2009 at 06:03:44PM +0100, Lyle wrote:
> Here is the next chapter. Once again all feedback greatly appreciated.
>
> Defined using the @ symbol in front of the array name, arrays store a
> list variables with numbered locations starting at 0. e.g
>
> my @array = (?one?, ?two?);
>
> stores ?one? at location 0 and ?two? at location 1. This is an important
> thing to note with a lot of computer arithmetic, numbering generally
> starts at 0.
To avoid confusion between one and 1, I suggest putting other data into
The array - aardvark, bat, coelocanth etc
> The default sort is an ASCII one, so A-Z goes before a-z. We'll cover
> more on sorting later.
Isn't cmp locale-sensitive?
> The if statement allows you to run a block of code if a condition is
> true. They are in the format:-
>
> if ( CONDITION ) {
> CODE
> }#if
Twitch twitch indentation twitch
> # Wrong way
> if ( $value = 0 ) { } # True
False.
$ perl -e 'if($v = 0) { print "true" }'
$
> Both examples return true. This is because the second one assigns 0 to
> the scalar $value which is a successful operation returning true.
The result of $foo = whatever is the resultiong value of $foo, which in
this case is zero, which is false.
> You also have OR, ||, AND, &&. OR and || do basically the same thing, as
> do AND and &&. There are subtle differences in preference, but I won't
> be covering them as the vast majority of the time they are interchangeable.
or and || are only subtlely different from and and &&? Errm. HELL NO.
I presume you're trying to make the point that or and || are roughly the
same and that and and && are also, but this needs re-writing.
Also note that capitalisation is significant. OR is a user-defined
function, or is a built-in operator.
> For general convenience and to make things read easier, unless is
> provided as an alternative to if not.
>
> if ( not( 9 > 10 ) ) { } # True
> unless ( 9 > 10 ) { } # Same
You may want to make the point that no-one in their right mind does this
...
unless(...) {
...
} else {
...
}
Because it's incredibly hard to parse in English.
On an unrelated note, it seems that you're doing things in a bit of a
weird order. I think aggregate data-types (arrays and hashes) should
be treated together, so move the section about comparisons and
conditionals to between scalars and arrays/hashes.
--
David Cantrell | Godless Liberal Elitist
More people are driven insane through religious hysteria than
by drinking alcohol. -- W C Fields
_______________________________________________
BristolBathPM mailing list
[email protected]
http://mailman.bristolbath.org/mailman/listinfo/bristolbathpm