#!/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 list 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 anything 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 $_; }