in reply to My first USEFUL script!

Comments, in no particular order:

As for a rating, your scale is difficult to work with ;-) I'd have to say that if it worked, the rating automatically is decent. The only caveat really is that last point: system tools may expect the system perl to be the one that the system installed. Playing with that is always dangerous. But that isn't a comment on your perl code, it's more a comment on your unix-fu :-)

(Congrats :->)

Replies are listed 'Best First'.
Re^2: My first USEFUL script!
by nefigah (Monk) on Mar 05, 2008 at 05:16 UTC
    Most appreciated :)
    • strict/warnings: I actually had those in the original script; as they are a part of the template that I set up for creating a new script (along with the shebang line and some #created on comments), I didn't copy and paste them. But I agree :D
    • $_: I'd been pointed to a general rule of thumb that explicitly saying $_ was to be avoided when possible (although that it is probably okay in grep/map). Glad to know there is some varying opinions on this though!
    • glob: Roger, I'll keep that in mind--is it faster or something?
    • blocks: Will keep that in mind as well
    • Renaming: I'll go back and take out the dot--it does make more sense. As to OS tools breaking, I think I'll go ahead and see what happens. I can always put the originals back in place if stuff is being weird. Thank you for the word of caution :)
    The rating scale tends to be easy use for the extreme ends of the scale, which is what I was concerned with ;) Thank you for looking this over!!
      Explicitly saying $_ is to be avoided when possible since you might as well as a meaningful variable name instead. However, that's obviously not the case when map/grep sets $_ for you.

      glob is more clear in general. For example, what does <FILE> do? Does it read a line (or all lines in list context) from the global filehandle 'FILE'? Or does it do a glob of 'FILE' in the current working directory? How about <$fh>? If $fh is "/usr/bin/perl*"? How about if $fh is an IO::File object? Or a reference to a global filehandle? If you want a glob, just use the glob function. That's what the <> does under the covers anyway.

      As for "stuff being weird" - you may not notice for 6 months... and by then you'll have forgotten that you replaced the system perl, and will beat your head against a wall trying to fix it ;-)

Re^2: My first USEFUL script!
by ikegami (Patriarch) on Mar 05, 2008 at 06:53 UTC

    not only does the BLOCK version work in all cases

    There's a situation where it fails. I can't remember what it is, but it might be when you create a closure inside the map block. (The solution is to add an extra pair of braces, creating a new scope.)

    Of course, you'd have the same problem if you used the EXPR form (if it's even possible to write the buggy code in EXPR form), so this doesn't weaken your point.