in reply to Re: newkid confused
in thread newkid confused: reverse then unreverse a string
Update: Cleaned it up a bit, thanks to BazB and podmaster for the assist#!/usr/bin/perl -wT #warnings and Taint checking on, see perlsec #CGI scripts should almost always use CGI.pm use CGI; use strict; #strict is your friend my $q = new CGI; print $q->header(); #print the header my $comment = "My lawyer is named will"; #this loops over the list in the parens, aliasing $new to each in turn #pointless, but presumably you anticipate having more than one in the +list for my $new ($comment) { $new = doit($new); #We act on $new, which will affect whichever lis +t element we're on } print $comment; #$comment, not $new. $new was only inside the loop sub doit{ my ($passed_string) = @_; #get the list we're passed, drop all but + first item #Note that I removed the "e" flags below, you aren't interpreting an +ything my $go = ";gi/moT/lliw/s ;gi/reknaB/reywal/s ;gi/yenraB/derf/s"; my $com = scalar reverse $go; $_ = $passed_string; #so that s// will work on it. eval $com or die $!; return $_; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re:(2) newkid confused
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 |