in reply to file test operations

@ikegami, I opted to use the open file handle to both open the file and/or create it if it doesn't exist. I seem to have irritated a few people when posting for help the first time and not including that line.

@javafan, I'm a newb so I don't really know all the benefits of each software package. Having said that, I gravitated towards Perl because of it's inherent regular expressions capabilities. I'm still working on Learning Perl (Schwartz) but hope to eventually make my way to CGI. Are there more efficient programming languages that I should be aware of?

@jethro, great advice!! Will keep in mind.

Replies are listed 'Best First'.
Re^2: file test operations
by jethro (Monsignor) on Feb 03, 2009 at 14:40 UTC

    Are there more efficient programming languages that I should be aware of?

    Javafans answer was a bit sarcastic because it doesn't really make sense to ask about efficiency around an open (which is maybe a thousand times slower than the following test you are worried about.

    There are faster languages about, for example C/C++ and assembly language. But that doesn't mean that YOU are faster in programming them. Or that it is as much fun programming in them. Tasks that are done in perl with a few lines need sometimes hundreds of lines in C. Pray that you have a fitting library at hand.

    For example, Hashes are used extensively in modern languages like perl, they are the bred-and-butter data structure and used for 80% of all data storage in a program. In C/C++ you can either:
    a) use a self-made data structure perfectly fitting the job, you only need 5 days instead of 1 to write the program and it might be noticably faster or not.
    b)use a hash library to get nearly the comfort of perl but also the same speed as perl for the handling of the data structure

    Don't get me wrong, if speed is all you care about, then use C/C++. If you need to write programs that have to make full use of every single memory bit and processor cycle of your machine, use C/C++. If you need to write low level hardware driver stuff, use C/C++. If you want to write programs faster, securer, testable, have better debugging, with more ease, have more libraries to choose from, want to use hashes and regex and other modern features extensively, want to program for the web or other high-level areas (i.e. far form the hardware), use perl.

    Note that you can combine perl and C-code (with limits) so it is often possible to write perl code and optimize the critical code parts with C code, if run time is critical