Re: Should I ask this question?
by ww (Archbishop) on Sep 30, 2009 at 22:27 UTC
|
The convention here is to use the CB to ask questions such as the one you've just posted (ie, don't use a SOPW to ask whether to post)
OR
just post a SOPW, with the code (inside code tags) and narrative notes (in para tags) asking about specific areas that make you wonder if the code is well written. If there are no snippets/segments/constructs about which you have doubts, a generic "How can I improve this?" can do little worse than fail to draw comments (unless it's so badly written that you draw downvotes for your exposition/formatting).
| [reply] |
Re: Should I ask this question?
by kennethk (Abbot) on Sep 30, 2009 at 22:27 UTC
|
Assuming you don't mind leaving your code up for the world to see, please do post it in the public forum. This site is about helping people learn and appreciate what Perl (note the capitalization on the language, perl is the program) can do for them. Sometimes it seems like most traffic on SoPW is "Why won't my code work?" and the OPs just want quick, one-off solutions or free code-writing. If you demonstrate a desire to understand Perl and show effort (and having written your script already shows effort), I think every person on this site will happily help you improve your methods and style.
As a side note, if your code is 150 lines, please wrap your code in <readmore> tags to avoid overwhelming the SoPW page. | [reply] |
Re: Should I ask this question?
by Marshall (Canon) on Oct 01, 2009 at 00:52 UTC
|
The key thing that I've seen in the last year (I'm relatively new)
is: whether or not you are working? Folks who are working and can
present questions based upon the code that they have written so far get a LOT
more help than those who aren't working.
I was working on an LWP program a couple days ago and got stuck. I posted the
code that I had so far on my scratchpad (after some hours of work) and asked for help in the Chatterbox.
I got enough help to "unstick my brain" and was able to complete the project. I had posted
code on my sctachpad before to help others, but that was the first time I asked others to
help me. And it worked!
james2vegas helped me out and provided very key info regarding a POST query
question. I worked
over the next 5 hours to finish the code. The whole project was more
complex than my question, but the answer to my question allowed me to move
forward and get the job done. PerlMonks is a good way to learn about new approaches and ideas that you need to spend more time thinking about.
In general, the more clear your question, the better the quality of the response will be.
| [reply] |
Re: Should I ask this question?
by bv (Friar) on Oct 01, 2009 at 14:55 UTC
|
Ok, let's see. Kudos for using strict and warnings!
I hope that helped, and good luck!
| print pack("A25",pack("V*",map{1919242272+$_}(34481450,-49737472,6228,0,-285028276,6979,-1380265972))) |
| [reply] [d/l] [select] |
|
|
Thanks for the input bv. Just the type of stuff I was looking for!
| [reply] |
Re: Should I ask this question?
by bv (Friar) on Sep 30, 2009 at 22:06 UTC
|
I haven't been here long enough to know if that would be frowned on, other than the fact that any honest attempt to learn will not be turned away. Why don't you post it on your scratchpad and those that wish can comment in this thread. If someone else says go for it, then post here as well.
| print pack("A25",pack("V*",map{1919242272+$_}(34481450,-49737472,6228,0,-285028276,6979,-1380265972))) |
| [reply] [d/l] |
Re: Should I ask this question?
by dsheroh (Monsignor) on Oct 01, 2009 at 07:50 UTC
|
You don't need to ask to ask. Just ask. | [reply] |
|
|
| [reply] |
Re: Should I ask this question?
by Bloodnok (Vicar) on Oct 01, 2009 at 09:26 UTC
|
Welcome, come inside ...
If you don't ask, you'll never know if you should have asked :-D
As others have suggested, don't be afraid to ask since the monks are only too glad to help if they can, even more so in the case of noobs and questioners that have obviously taken the time & trouble to attempt to solve the problem for themselves .
They [the monks] only tend to take exception when they feel that the questioner is taking the mickey &/or being award winningly stupid/obtuse.
A user level that continues to overstate my experience :-))
| [reply] |
Re: Should I ask this question?
by ELISHEVA (Prior) on Oct 01, 2009 at 19:40 UTC
|
Welcome to PerlMonks!
Your indenting is a bit funky. I think you might find it easier to read if you used a more conventional style. There are two basic styles: cuddled and uncuddled, but both indent the code within the braces. This makes it easier to see which flow-of-control statements control which lines.
Here is an example using cuddled curly braces:
sub Wanted {
my $orig_dir = cwd;
if (-d $_) {
chdir $_;
# more code ...
foreach my $file (@music_files) {
chdir $_;
$file =~ s/ /%20/g;
#more code here
}
}
}
And here is the uncuddled version
sub Wanted
{
my $orig_dir = cwd;
if (-d $_)
{
chdir $_;
# more code ...
foreach my $file (@music_files)
{
chdir $_;
$file =~ s/ /%20/g;
#more code here
}
}
}
Your code sample actually uses a mix of both the cuddled and uncuddled style. It is generally a good idea to be consistant and follow one style or another. That way your readers don't have to do mental flip-flops while reading the code. They can also focus on your code rather than trying to remember that you prefer cuddled for foreach but uncuddled for if...else or vice versa.
Best, beth | [reply] [d/l] [select] |