Re: very tight perl syntax
by planetscape (Chancellor) on Jun 03, 2011 at 21:22 UTC
|
| [reply] |
|
|
I think your advice is good as usual but without evidence to the contrary I suspect "very tight" means "written by a self-absorbed bastard with a background in C and shell scripting who thinks 2 letters is a bit on the long side for variable names, field-specific formulas and algorithms do not need comments because everyone else should at least have a Masters in the same discipline, multiple shell operations are better than CPAN modules and ought to be inlined with Perl in a style from 1997, and no operation should ever, under any condition, be tested for failure, success, or security because what would be the point, right?"
...quoth the hacker who has inherited too many code-bases written by PhDs.
| [reply] |
|
|
| [reply] |
Re: very tight perl syntax
by BrowserUk (Patriarch) on Jun 03, 2011 at 22:03 UTC
|
As with any problem, tackle it one bit at a time. Try posting the shortest subroutine that you find most indigestible and highlight the bits you don't understand.
Then use the knowledge you gain from the explanations given here, to add brief comments to similar constructs in the rest of the code.
Then isolate the next routine that still taxes you and post that.
This should get you up to speed on what is there very quickly and will allow you decide whether the comments are enough, or if you want to refactor to your tastes.
You may find that once you've learnt to recognise the constructs, that you are happy with them.
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
| [reply] |
Re: very tight perl syntax
by zek152 (Pilgrim) on Jun 03, 2011 at 19:53 UTC
|
Depends on the question. If it is about 1 line of code then the chatterbox is probably a good choice. If you are talking about 40 lines of code then make a node with the question.
Basically if you can't fit the code in one line on the chatterbox it is probably too big. You could use your scratchpad if you prefer to not make a node.
Update. If you do have questions about your code please try to title them well. Read How do I compose an effective node title?. The title "very tight perl syntax" is ambiguous and does not provide insight into what you are really asking.
| [reply] |
Re: very tight perl syntax
by ikegami (Patriarch) on Jun 03, 2011 at 20:37 UTC
|
[ I moved your post. Discussions about PerlMonks belong in PerlMonks Discussion. ]
zek152 already answered. I just wanted to add that perl -MO=Deparse,-p a.pl, perl -MO=Deparse a.pl and perltidy might help you figure out some of your puzzles.
| [reply] [d/l] [select] |
Re: very tight perl syntax
by toolic (Bishop) on Jun 04, 2011 at 13:03 UTC
|
Before you post, make sure you search and read through the Perl documentation, which is also conveniently available at you command line:
perldoc -q sort
perldoc -v $_
Also, you should copy-n-paste code snippets into a separate script so that you can stimulate and observe on your own. If your "talented programmer" has structured the code well, this should not be too much trouble for you.
| [reply] [d/l] |
Re: very tight perl syntax
by JavaFan (Canon) on Jun 04, 2011 at 17:26 UTC
|
I have to figure out/maintain this 40 page program.
It'll be a waste of time to fully understand this program. Deal with it when it needs to be "maintained" (whatever 'maintained' is going to mean - add new features, fix bugs, compile on a new platform, apply new paint), and then deal with it - and only deal with those parts that need dealing with.
| [reply] |
|
|
If the program is not that important your advice is good. But if other teams rely on it, his manager considers it important (for whatever reason), or it's business critical, then unless there is a good test suite/environment he needs to learn enough of the program to be able to tell if what appears to be a minor change really is. Seems to be pretty weak advice given that the odds of there being a good test suite/environment are likely approaching negative infinity.... Update: Maybe better advice would writing a test suite for the program and then try and refine it to "good" status. Though that would still not help with estimating how much effort is needed to make changes to the code.
| [reply] |
Re: very tight perl syntax
by planetscape (Chancellor) on Jun 20, 2011 at 16:41 UTC
|
| [reply] |