in reply to Re: Question on style/technique
in thread Question on style/technique

There are of course many programs that you do not want to issue any warnings if they cannot open certain files. Lots of application read in various, optional, configuration files, one in the current directory, one in the users home directory, and a system wide config file. Not all config files will exist, or are readable. You want the application to silently skip them. This is very acceptable code:
foreach my $file (@files) { if (open my $fh => $file) { read in file do whatever you need to do } }

-- Abigail

Replies are listed 'Best First'.
Re: Re: Question on style/technique
by synapse0 (Pilgrim) on Jul 06, 2001 at 07:34 UTC
    Thanks for the replies everyone, Abigail hit on the mark what i am doing with my code. I often have instances where i just need to grab a bit of data from a file, or append a string, something that can quickly be done in a block and filehandle closed, and something that doesn't necessarily need to happen.. I just didn't know if this might be percieved as "bad coding" practice, since i've never seen it done like that in other's examples.
    Once again, thanks...

    -Syn