![]() |
|
There's more than one way to do things | |
PerlMonks |
Re: Adjacent numbers - the plain wayby Discipulus (Canon) |
on Nov 20, 2015 at 10:41 UTC ( #1148216=note: print w/replies, xml ) | Need Help?? |
Hello melissa_randel and welcome to the monastery and to the wonderful world of Perl as a tip for your next posts i suggest to include some code you tried: you show more effort and the help can be better targeted at your level of wisdom: infact you had got good and very good replies to your question, but how many of them you understand completely? Me too I dont understand the smart Anonymous's almost oneliner: i would need to refill it with a lot of print statements before understanding it. Because of this i think the best approch is what the wise choroba presented you as first reply: think about your problem in words and then translate into Perl. I've started learning Perl with no programming nor scientific backgroud and after a decade of Perl i'm start thinking that the compiler is happier with plain basic code. Me too nowadays I tend to write 'smart' code but i think is often a matter of self exstimation more that a matter of quality. So the code I present you will be easy and commented for a full understanding. Obviously concise code is a good thing. But someone here at PerlMonks once said:Dont code at your best. Being to debug twice difficult then write code, you'll not be able to debug, by definition so in the above code: can be shortned (imagine a long list to process) into But i suspect is not faster nor more efficient: is just more concise and uneasier to debug: the plain, kid version is the easiest to debug (because you'll get the exact line number of the statement producing the error!):
HtH L*
There are no rules, there are no thumbs.. Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.
In Section
Seekers of Perl Wisdom
|
|