Well, let's see what you're actually doing:
$comment = "My lawyer is named will"; for ($new = $comment) { $comment = &doit($comment); }
Okay, this is probably not what you intend. This takes $new, and sets it equal to $comment. Then this is treated as a list (of 1 item), which is assigned to $_ in the for loop (the s// will by default work on $_), and then $comment is set equal to the result of doit().
sub doit{ $go = ";gie/moT/lliw/s ;gie/reknaB/reywal/s ;gie/yenraB/derf/s";
This sets $go equal to that string.
$com = join("", reverse split(//, $go));
This sets $com equal to the result of this.
return $com; } print $new;
which is then returned ($new being set equal to that).

It seems you want to _run_ those searches against $new. You'll want an eval() statement to do that. (Why is left to your own twisted goals). I suggest you study the for() loop because I suspect you are misunderstanding what it is doing.

Update: eval() can be a security risk if you are running anything that can be affected by user input, particularly on a web page. I suggest you use perl's taint mode, and CGI.pm


In reply to Re: newkid confused by swiftone
in thread newkid confused: reverse then unreverse a string by caciqueman

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.