in reply to Using scalar values as conditionals

You are focussing to much on the details of the example. Don't forget this example comes from a book. Books are small. Code fragments in books need to be even smaller.

In a real program, the $name gt 'fred' could be a long, expensive expression, whose value is needed more than once. Or the comparison between $name and 'fred' and if statement has some code between it, code that may, or may not modify $name.

Abigail

Replies are listed 'Best First'.
Thanks, Re: Using scalar values as conditionals
by amarceluk (Beadle) on May 28, 2002 at 17:02 UTC
    Yes, very good points. In particular, I hadn't thought about there being code that might modify $name. Thank you!

    I guess I do focus too much on the details because I'm still at an early stage of learning and I try very hard to understand exactly how everything works, but don't have enough knowledge/imagination to see how the example being demonstrated might be used in real code. Hopefully as I write more real code it'll be easier to understand these things!

    __________
    "Abby-somebody. Abby-normal."
    Young Frankenstein