Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
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.

Replies are listed 'Best First'.
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 making s'mores by the fire in the courtyard of the Monastery: (9)
As of 2016-08-30 20:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    The best thing I ever won in a lottery was:















    Results (423 votes). Check out past polls.