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

Re: Seeking guidance for more idiomatic way of (re)writing this script.

by Anonymous Monk
on Jan 15, 2013 at 11:03 UTC ( #1013357=note: print w/ replies, xml ) Need Help??


in reply to Seeking guidance for more idiomatic way of (re)writing this script.

if (open ...) { print error } else { real code here } #EOF

is better written as

if (open ...) { print error exit(1); } real code here

Besides that, you might want to try splitting the script's processing stages into well-named subroutines. It will help you reduce the amount of variables in the current scope, too. And perhaps rid of the temporary file -- I'm sure MIME::Lite can attach a "file" from a string variable.


Comment on Re: Seeking guidance for more idiomatic way of (re)writing this script.
Select or Download Code
Re^2: Seeking guidance for more idiomatic way of (re)writing this script.
by Anonymous Monk on Jan 15, 2013 at 11:04 UTC

    use autodie 'open';
    open ...; # autodie prints error message/exits on failure -- it dies
    ...

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (6)
As of 2015-07-07 01:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (86 votes), past polls