Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
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?
[Discipulus]: ok try it in Eatalian ;=)
[Eily]: Discipulus I don't suppose you can do the same for me can you ? :P
[Discipulus]: Eily tongue twister or votes? ;=)
[Eily]: Discipulus turn me into a Bishop
Discipulus abracadabra.. Eily tranformed into a.. shop for bisexual peoples..
[LanX]: Eily don't be sad ... you are the Bishop of our hearts.
[marto]: 1nickt, I just said that in a Sean Connery accent
[LanX]: Discipulus++ # Bi-Shop
[Eily]: is the Bishop of hearts higher or lower ranked than the Jack?
[ambrus]: Higher.

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (13)
As of 2017-09-26 12:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    During the recent solar eclipse, I:









    Results (294 votes). Check out past polls.

    Notices?