Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: Re: Re: First Unix Admin Script - Request for Constructive Critisism

by D.Millin (Beadle)
on Feb 08, 2003 at 21:13 UTC ( #233777=note: print w/replies, xml ) Need Help??


in reply to Re: Re: First Unix Admin Script - Request for Constructive Critisism
in thread First Unix Admin Script - Request for Constructive Critisism

Thanks for the head up on IO:File. You mention that the script isn't good style. I would appreciate any advise, in this area, as I am just leveraging perl into what I have seen in ksh.
  • Comment on Re: Re: Re: First Unix Admin Script - Request for Constructive Critisism

Replies are listed 'Best First'.
Re: Re: Re: Re: First Unix Admin Script - Request for Constructive Critisism
by grantm (Parson) on Feb 09, 2003 at 02:55 UTC

    The comment about style merely related to calling open() but not calling close(). In your script, it's really not a problem - each subsequent call to open() will close the previously opened file since the same filehandle is used each time. The last filehandle will be closed when the script exits.

    IO::File allows you to store your filehandle in a normal scalar - which is especially useful if you want to pass it to a subroutine. You would typically use a lexically scoped scalar (one declared with 'my') so that the filehandle was not global.

    Regardless of which form of open you use, as tall_man said, you should always check the return value and at the very least call die "$!" if it fails.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (5)
As of 2023-12-11 16:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What's your preferred 'use VERSION' for new CPAN modules in 2023?











    Results (41 votes). Check out past polls.

    Notices?