in reply to How NOT to do it

You know, I think I'm to blame for this. The Llama book never mentions the length operator at all, and that was by design. Almost any time I've seen people need the length of the string, they were about to cycle through the string character-by-character (as you might need to do in other languages), and therefore miss the more natural and powerful regular expression operations. Since I teach regex very early on, there's usually no need for length.

The hardest part about a tutorial book is coming up with a teachable, self-consistent, useful subset of the language. Many decisions to be made.

-- Randal L. Schwartz, Perl hacker

Replies are listed 'Best First'.
Re: Re: How NOT to do it
by jlawrenc (Scribe) on Mar 18, 2001 at 21:28 UTC
    NO, I disagree! I think that there is a certain level of reasonability to be expected here. If the person in question really thinks about it - Perl's origins stem from the need to crunch through tomes of text. There stands to reason that our traditional string functions like lenght, substring, etc., would be in the language right from the get go!

    I think the hardest part about tutorials, teaching students, or developing staff is fostering the correct foundations of common sense.

    Maybe what we need is a tutorial on how to RTFM. That was one skill I learned early on in my career. :)

Re: Re: How NOT to do it
by Kickstart (Pilgrim) on Mar 19, 2001 at 08:04 UTC
    So what is the shortest way we can rewrite this code?

    Kickstart

      Another fellow monk once wisely showed me the path to enlightment with the length func.

      -= Ozzy =-

      Edit: chipmunk 2001-03-18