On Saturday 28 February 2004 9:58 am, John W. Krahn wrote: > Gary Stainburn wrote: > > Hi folks, > > Hello, > > > as many of you who follow this list will know, a while back I decided to > > learn OOP and set myself the task of simulating a railway system. > > > > A number of people asked if I could make the code available for viewing > > in order to help me with my questions. > > > > I think that I have now done enough of the coding to show my intentions. > > I am (not very) quietly chuffed with what I've achieved so far. > > ^^^^^^^ > Is that a good thing or a bad thing?
This was an accidental play on words. In the context I used it, it means proud, pleased with ones self. However, it also means the amount of steam that a loco has, and therefore how well it's working. > > > Many thanks to all who helped. For those who are interested, the code is > > available at http://www.stainburn.com/trainset-0.0.1.tgz > > James already made some good points on which I concur, especially adding > whitespace! I usually run unknown code through Perltidy which really > improves readability. James also mentioned nested subs. If you define > a sub inside of another sub it may appear that the sub is only visible > inside that sub however sub names are package variables and are visible > anywhere in the entire package. If you want a lexically scoped sub you > have to assign a sub reference to a lexically scoped scalar like: > > my $sub_name = sub { do something }; This was a last minute thing that I did to try to reduce the amount of code. (I think it camde from my Pascal days). What I really want is to be able to replace if (some condition) { print "some message" if ($verbose); return 0; } with barf("some message") if (some condition); combining the if/print and the return in one. This would mean that the return would have to return from 2 subs (barf and he caller). I don't know if this is possible, but I seem to remember a recent thread on goto mentioned a special way of using it to do something similar. I'll have to look into it. > > > > John -- Gary Stainburn This email does not contain private or confidential material as it may be snooped on by interested government parties for unknown and undisclosed purposes - Regulation of Investigatory Powers Act, 2000 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>