Oh dear.

Allow me to quote from talexb's reply to a post earlier today:

I'm guessing that you won't get much (serious) help on this -- you're asking us to spend significant time to debug a piece of code. You've come to the wrong site for that. Here's what this site (and community) is about: you bring your boiled-down, condensed, pithy Perl question to us, and we give you lots of varied answers and different approaches. You learn something, and perhaps we do too. I suggest you go away and do some work on your question, and come back when you've narrowed it down a bit...

We don't want to see your entire code (in particular, when you've learned a little more about Perl, you'll be ashamed about stuff such as:

if ($subscript == 1) { $aphor = $aphor1 } elsif ($subscript == 2) { $aphor = $aphor2 #... up to and including elsif (subscript == 7) { .. }

but as you're learning, at present, that's OK).

But what's not OK is to post the whole mess here. Note my emphasis of talexb's 'boiled-down, condensed, pithy' (if you don't know what 'pithy' means, well, er... it's pretty much the same as 'condensed' (or 'boiled-down' :) ).

I simply don't have the time to look through all of your 135 lines (in my editor) of code, and I imagine that most other Monks don't, either.

The moral is: Condense it! Boil it down! Extract the pith!

First, for example, your question has nothing to do with command-line processing, so take out all the stuff about @ARGV.

Second, we don't need to know how you define and select your aphorisms according to user input. If you have a problem with parsing user input, make it the subject of a separate post, not one entitled 'unexpected behavior with split'. This means that you could replace 43 lines (in my editor) of code (including the @ARGV stuff) - from if ($subscript == 1) { to the '}' just after die "ARGV out of range"; - with just one line, namely:

my $aphor = 'whatever';

where 'whatever' corresponds to one of the aphorisms that you are having problems with.

How to post condensed (boiled-down, pithy) code: Let's say I write some code that Perl doesn't want to compile (a regular occurrence, I assure you). After examining the error messages, and correcting my most ridiculous mistakes, and other stuff, if it still doesn't do what I want, I postulate that there might be an error in the line:

my @sect = split /$splBRK/;

So, I create a new perl file (I call it 'test.pl', YMMV):

use strict; use warnings; my $str = 'aa~~bb'; my $splBRK = '~~'; my @sect = split /$splBRK/, $str; print "<$_>\n" for @sect;

Well, it seems that test.pl (after trying as many test cases as I can think of) works as expected , implying that the problem is elsewhere in my code. So, ikegami++ (how I envy his/her patience!) is probably right.

I could go on, but I think that a Tutorial entitled 'Basic Debugging' (or something...) might be in order. A lot of interesting stuff has already been posted in PM, such a tutorial could be mainly just be a synthesis of these nodes, but time (as ever) is not extensible...

dave


In reply to Re: unexpected behavior with split by Not_a_Number
in thread unexpected behavior with split by ww

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.