in reply to Perl File Parsing - My Code Works, but it's Ugly!

Nothing huge, but some cleanup things:

Aaron B.
Available for small or large Perl jobs and *nix system administration; see my home node.

Replies are listed 'Best First'.
Re^2: Perl File Parsing - My Code Works, but it's Ugly!
by Nico (Novice) on May 31, 2015 at 20:55 UTC

    Thank you for your response! I have no idea what I was thinking with those opens and closes. I only need to specify them once at the beginning of the script, and I can use them throughout the script.

    I removed the junk variables and removed Time::Local. It works!

    I will need to figure out how to error check my mkdir statements. But luckily I only have those two statements there so shouldn't be too hard

      You can error-check mkdir much like you do open:

      mkdir $newdir or die "Unable to mkdir $newdir : $!";

      That's true of most commands in Perl; they return true if successful and false on failure, so you can use "do_this() or show_error()" logic. (One exception is system, which returns the return value of the underlying command, which (on Unix at least) is zero on success, so you have to watch out for that.)

      Aaron B.
      Available for small or large Perl jobs and *nix system administration; see my home node.