Linicks has asked for the wisdom of the Perl Monks concerning the following question:

Well, I was a bit of a fool on this one (the brown paper bag question)

What I was not thinking was to pass a substution via a request{} variable like this 's/find/replace/'

Duh! I missed that perl easy expands $vars in the context anyway. All you need do is set a $find and $replace var from the form and do this:

if (length ($request{'find'}) > 0 ) { $line =~ s/$request{'find'}/$request{'replace'}/; }

Nick

Replies are listed 'Best First'.
Re: Pass CGI HTML form $vars to script - REVISITED
by choroba (Cardinal) on Sep 08, 2016 at 07:39 UTC
    It seems you forgot to include the link to the previous question.

    [id://1170905]Passing a regex from a CGI HTML form

    ($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,

      Thanks!

      Nick

Re: Pass CGI HTML form $vars to script - REVISITED
by Anonymous Monk on Sep 07, 2016 at 22:07 UTC
    What is the question? For whose benefit is this discovery?

      If you see the thread linked in the comment below, my original question ended up with a lot of debate about using EVAL on a user form $var supplied via CGI script. As my post states, I wasn't thinking right, so corrected it here.

      Nick