in reply to Re^13: Perl OO and accessors
in thread Perl OO and accessors

I can't see any advantage to having them as variables. Can you?
$ echo "'$RANDOM' is a random number"
Perl --((8:>*

Replies are listed 'Best First'.
Re^15: Perl OO and accessors
by fergal (Chaplain) on Dec 01, 2005 at 00:58 UTC
    Is that supposed to be an argument for having them as variables? If Bash had a function named random rather than a variable then you could do this
    echo "'$(random)' is a random number"

    If the extra ()s are too much of a burden then the logical conclusion is that everything should be a variable just to make it easy to do in string interpolation.

    The principle of least surprise means that you shouldn't make something look like a variable if it's not going to behave like one. For example

    MINUTES=5 echo $MINUTES # 5 SECONDS=5 echo $SECONDS # 1276

    How can that be a good thing? There's not even a warning.

    Also, having variables that aren't leads to run time errors that could have been caught at compile time. If random was a function, attempting to assign to it would be an error (at runtime in bash but at compile time in perl).