Comment on

 Need Help??
Aarrrgghhhh!!! I'm going crazy here. I can't seem to figure out why something is working the way it is; could any of you help me? I left all my debugging print statements there so that you can run it yourself and see the same results.
```
sub b {
print 'args=',join(",",@_),"\n";
\$,=pop()-pop();
print ", = \$,\n";
\$x=join'',sort split//,\$,;
print "x = '\$x'\n";

## the line below doesn't seem to work!!
@_=map{scalar reverse(\$_),\$_ } \$x;

print "\@_ = ",join(",",@_),"\n";
print "\n";
\$,==495?0:1+b(@_);
}

sub c {
@a=map{ scalar reverse(\$_),\$_ } pop;
print join(",",@a),"\n";
}

c(312);
b(312);

====
Results when run<
====
213,312              ## this is c()
args=312             ## this is b()
, = 312
x = '123'
@_ = 312321,123312
For some reason, the map statement in b() is resulting in that strange "312321,123312" results ... which for the life of me, I can't figure out why.

I have a feeling it's something stupid, but I can't see it. Can anyone else?

Update: God, I love this place. You write a technical, perl question, one that contains a user-error (such as I did, using \$, as a temporary variable (golf, you know)), and you get down voted as much as upvoted. This node of mine has bounced from -1 to 1 so many times my head is spinning. So at what point is a question stupid enough that you shouldn't ask? I seem to remember quite a few people having on their tag lines, and on their tongues, the phrase of "Ask a silly question, be a fool for a minute, don't ask a silly question and be a fool forever.". I guess that doesn't always apply, huh?</rant>

mr.nick ...

In reply to Re: (Golf) Kaprekar's Process by mr.nick
in thread (Golf) Kaprekar's Process by srawls

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.
• Posts may use any of the Perl Monks Approved HTML tags:
a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, 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, 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: & & < < > > [ [ ] ]
• Link using PerlMonks shortcuts! What shortcuts can I use for linking?

Create A New User
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (4)
As of 2017-06-27 12:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
Voting Booth?
How many monitors do you use while coding?

Results (604 votes). Check out past polls.