Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: Question on style/technique

by Abigail (Deacon)
on Jul 06, 2001 at 06:05 UTC ( #94362=note: print w/replies, xml ) Need Help??


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

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://94362]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (4)
As of 2021-02-28 19:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?