in reply to Re^2: Writing to file...
in thread Writing to file...

1. I've never had problems with glob except where spaces appear in the pattern, and then I use File::Glob 'glob';. I did not here because I thought it an unnecessary complication. KISS. If it is that easy to produce a portable version using opendir/readdir/closedir then one wonders why glob is not fixed in the base.

2. I used to use BSD style braces until I discovered TheDamian's Perl Best Practices.

3. Whitespace? I thought everyone coded like that.

4. It is a good idea to do a closedir (I'm sure you knew that).

Update: improved format.

Replies are listed 'Best First'.
Re^4: Writing to file...
by Marshall (Canon) on Jul 22, 2009 at 12:43 UTC
    This glob thing is just a mess. Part of the reason is the spaces that are allowed in some Windows file systems as you have noted! Youch! I beat the doo-doo out of an Active State app trying to get glob to work. Some of the modules worked with DOS glob and some with BSD glob.  use File::Glob 'glob'; is not a magic cure all. This BSD vs Sys V thing is weirder to understand. Anyway, I've spent many hours in "glob hell" and I just don't do it anymore.

    Yes, closedir is the "right thing to do"! Every file handle comes from a limited pool of system resources. For a 20 line program, I don't worry about it much, but as they say "your mileage may vary". If this 20 line thing is in a client-server app, well then an open file handle here and there adds up! And the application bombs!

    I tutor some students at a local college and one fundamental mistake is lack of whitespace and separating "thought units", but you see that too!

    I have ammended my evil 'C' ways in favor of lining up braces. I am quite sure that this is the best way and I don't understand why you don't think that it is.

    Anyway I say Horray! The OP has some good code to work from and I think he/she will do a great job!