> Either quote the meta characters in the search string by enclosing it > in \Q \E sequences or quote each meta separtately by preceeding > it with a \ character, e.g. > > s!\Q$search\E!$replace!; > > or > > @search=split(//,$search); > foreach $char (@search) { > $char="\\$char" if $char=~/\W/; > } > $search=join('',@search);
I still couldn't get it to work. Here is my code so you can see where I am messing up: # Get the original record from a hidden field my $record = $cgi->param('oldval'); # Search the database, and grab the old values for the record to be modified open (OLD, "$file") or die "Cannot open $file: $!\n"; while (<OLD>){ $oldline = $_; if ($oldline =~ /^$record(.*)$/) { ($orig_cat_num, $orig_link, $orig_name, $orig_file, $orig_title, $orig_composer, $orig_arranger, $orig_publisher, $orig_price, $orig_description) = split(/\:/, $oldline); # Store the value of this line in the search variable $search = $oldline; } } # Close the file close (OLD); # Grab the new values from the form $cat_num = $cgi->param('cat_num'); $title = $cgi->param('title'); $composer = $cgi->param('composer'); $arranger = $cgi->param('arranger'); $publisher = $cgi->param('publisher'); $price = $cgi->param('price'); $description = $cgi->param('description'); # Get rid of all the line enders in the description $description =~ s/\n/\<br\>/g; my $replace = "$cat_num:$orig_link:$orig_name:$title:$composer:$arranger:$publisher:$price :$description\n"; open (OFILE, "< $file") or print "<br>Cannot write the database"; open (TEMP, "> $tmp") or die "Cannot create temp file: $!\n"; select (TEMP); my $out = ''; # Print all the lines of text from the db file directly into the temp file, # including the record header we are looking for while (<OFILE>){ my $line = $_; if ($line =~ /^$record(.*)$/i) { chomp $line; # Substitute the old values for the new $line =~ s!\Q$search\E!$replace!; # This still shows the old value!!! die "Replacing with $line\n"; $out .= $_; } $out .= $_; } print TEMP $out; Now, as I mentioned before, the contents of $line would look like: ../pdf/sax_quartet/BMP0016.pdf:BMP0016.pdf:No baile mas (Dance No More):Cervantes:O'Briant:Bayside Music Press:$8.00:desc<BR> Where am I going wrong? -Erich- _______________________________________________ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs