Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > resolve single line with multiple items into mutliple lines, single items

Reply
Thread Tools

resolve single line with multiple items into mutliple lines, single items

 
 
Uri Guttman
Guest
Posts: n/a
 
      04-06-2009
>>>>> "BM" == Ben Morrow <(E-Mail Removed)> writes:

>> exit(0);


BM> There is no need to exit() from a Perl program under normal
BM> circumstances. Falling off the end will exit successfully.

i like to have explicit exits in my main program. i usually keep the top
level inline code very short with a few key lexicals and top sub calls
and then exit(). then come the subs in some semblance of order. arg
parsing and help/usage subs always go to the bottom out of the way. this
is how i teach to write scripts so they are easy to develop AND
read. and the explicit exit tells you the top level code is done and you
don't have to scan for it (or fall to the bottom) to see any more main
level code.

uri

--
Uri Guttman ------ http://www.velocityreviews.com/forums/(E-Mail Removed) -------- http://www.sysarch.com --
----- Perl Code Review , Architecture, Development, Training, Support ------
--------- Free Perl Training --- http://perlhunter.com/college.html ---------
--------- Gourmet Hot Cocoa Mix ---- http://bestfriendscocoa.com ---------
 
Reply With Quote
 
 
 
 
ccc31807
Guest
Posts: n/a
 
      04-06-2009
On Apr 6, 1:49*pm, Uri Guttman <(E-Mail Removed)> wrote:
> i like to have explicit exits in my main program. i usually keep the top
> level inline code very short with a few key lexicals and top sub calls
> and then exit(). then come the subs in some semblance of order. arg
> parsing and help/usage subs always go to the bottom out of the way. this
> is how i teach to write scripts so they are easy to develop AND
> read. and the explicit exit tells you the top level code is done and you
> don't have to scan for it (or fall to the bottom) to see any more main
> level code.


I agree fully.

As a matter of style, you can write functions that only receive
arguments and return values with no side effects or assignments
withing the functions, or you can write functions that make
assignments and have side effects.

Philosophically, I'm inclined to the first style, and attempt to write
in that style.

In practice, I normally write in the second style, so that my 'main'
program is very short and consists on of a sequence of function calls
(followed by exit(0)). The bulk of the work, including variable
assignments, are done by my user defined functions.

I'm tending now to use a lot of modules, so that my 'main' program
still consists of sequences of function calls, my user defined
functions still avoid side effects and assignments as much as
possible, and the dirty work is done in the modules. I don't
particularly like this, and my style will probably continue to change.

Your thoughts?

CC
 
Reply With Quote
 
 
 
 
Uri Guttman
Guest
Posts: n/a
 
      04-06-2009
>>>>> "c" == ccc31807 <(E-Mail Removed)> writes:

c> As a matter of style, you can write functions that only receive
c> arguments and return values with no side effects or assignments
c> withing the functions, or you can write functions that make
c> assignments and have side effects.

it varies. in some cases a few top level lexicals are ok by me.

c> I'm tending now to use a lot of modules, so that my 'main' program
c> still consists of sequences of function calls, my user defined
c> functions still avoid side effects and assignments as much as
c> possible, and the dirty work is done in the modules. I don't
c> particularly like this, and my style will probably continue to change.

you can always pass in a main hash ref to keep all the top level
stuff. as i said, it varies based on my mood and the complexity of the
program's top level.

uri

--
Uri Guttman ------ (E-Mail Removed) -------- http://www.sysarch.com --
----- Perl Code Review , Architecture, Development, Training, Support ------
--------- Free Perl Training --- http://perlhunter.com/college.html ---------
--------- Gourmet Hot Cocoa Mix ---- http://bestfriendscocoa.com ---------
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
src-resolve: Cannot resolve the name ... ivanet@gmail.com XML 1 03-23-2007 12:10 PM
[nio] Mutliple Messages in ByteBuffer Michael B Allen Java 1 12-13-2004 06:30 AM
mutliple CPUs, threading and JVM 1.4.2 David Java 0 11-03-2004 07:29 PM
Mutliple Virtual Profiles with local AAA Andy Gray Cisco 7 10-29-2003 02:22 PM
Single signon (with FormsAuth) for mutliple web apps Brad ASP .Net Security 3 09-26-2003 02:24 AM



Advertisments