in reply to newkid confused: reverse then unreverse a string
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().$comment = "My lawyer is named will"; for ($new = $comment) { $comment = &doit($comment); }
This sets $go equal to that string.sub doit{ $go = ";gie/moT/lliw/s ;gie/reknaB/reywal/s ;gie/yenraB/derf/s";
This sets $com equal to the result of this.$com = join("", reverse split(//, $go));
which is then returned ($new being set equal to that).return $com; } print $new;
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re:(2) newkid confused
by swiftone (Curate) on Apr 05, 2002 at 22:07 UTC | |
by caciqueman (Novice) on Apr 05, 2002 at 22:52 UTC | |
by tadman (Prior) on Apr 05, 2002 at 23:55 UTC | |
by belg4mit (Prior) on Apr 06, 2002 at 00:19 UTC |