in reply to Grade me! TAC

Just a a general comment on perl coding style, try to make use of the $! variable in errors like this,

open ( MYFILE, " $fileName" ) or die "Cant open file $fileName: $!\n";

Replies are listed 'Best First'.
Re^2: Grade me! TAC
by davido (Cardinal) on Jun 11, 2004 at 15:45 UTC
    Ok, I'll bite. Why? \n requires simple double-quotish interpolation to work. $/ requires double-quotish interpolation, plus variable lookup in the symbol table.

    $/ can also be re-set by the script to some other value (other than \n). If the script sets $/ to "End of Record", and you use $/ in place of \n... well, you know what it's going to print.

    I don't mind seeing $/ here and there in one-off scripts, but can't imagine why you would use it to represent \n in a script that's going to be around awhile. It's definately not something you would read in perlstyle.

    Maybe I missed the point?

    UPDATE: Yes, I missed the point. The italics font made $! look like $/. Sorry everyone. :)


    Dave

      Look closely. grid6507 is advocating the use of dollar-bang, not dollar-slash. (Though it does look kind of like a slash in italics, doesn't it?).
        Good grief, the font got me! Yes, by all means use $! (dollar bang). Sorry folks, pay no attention. ;)

        Dave