Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much

Re: Pattern Match and Replace Problem

by belize (Deacon)
on Apr 27, 2001 at 23:50 UTC ( #76245=note: print w/replies, xml ) Need Help??

in reply to Pattern Match and Replace Problem

Will this work:

foreach $File (@File) { $File =~ s/\n//; foreach $Field (@InputFields) { $ReplaceVar = $FORM($Field); $ReplaceVar2 = ''; $SearchVar = '\[' . Field . '\]'; $SearchVar2 = '\['.*'\]'; $File =~ s/$SearchVar/$ReplaceVar/g; $File =~ s/$SearchVar2/$ReplaceVar2/g; } print "$File\n"; }

Can I run a search and replace on a line, then run a second one consecutively to catch the ones that weren't replaced. Doesn't seem to work for me? Why not?

Replies are listed 'Best First'.
Re: Re: Pattern Match and Replace Problem
by Chady (Priest) on Apr 27, 2001 at 23:56 UTC

    How are you recieving your form data?? I assume with ??

    If that's the case... try this when you read the data:

    use CGI; $q = new CGI; $Field1 = $q->param('Field1) ? $q->param('Field1') : ' '; $Field2 = $q->param('Field2) ? $q->param('Field2') : ' '; # and so on...

    This way, if someone didn't fill in the "Field1" it will be replaced by a space character... or whatever you specify.

    He who asks will be a fool for five minutes, but he who doesn't ask will remain a fool for life.

    Chady |

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://76245]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (3)
As of 2021-10-24 01:26 GMT
Find Nodes?
    Voting Booth?
    My first memorable Perl project was:

    Results (88 votes). Check out past polls.