Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl $filename = "test.txt"; $termsfile = "test.list"; open filename or die "Can't find file $filename: $!\n"; @terms = `cat test.list`; foreach (@terms) { chomp; } $count = 1; while (read filename, $buf, 16384) { @buf1[$count] = $buf; $count++; } foreach $term (@terms) { ($search, $replace, $junk) = split /\#\#SPLIT\#\#/, $term; print STDOUT $search; print STDOUT $replace; print "\n"; foreach $buf2 (@buf1) { $buf2 =~ s/$search/$replace/g; } } print STDOUT @buf1; close filename;
The script will go through a file and convert all 'tabs' to TABMARKHERE. But it converts all .END to the exact text of .ENDTAGHERE\t. Can someone please help me figure out this problem?The file it reads the terms from looks like. .END##SPLIT##.ENDTAGHERE\t \t##SPLIT##TAGMARKHERE
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Problems with a search and replace script
by Hot Pastrami (Monk) on Mar 22, 2001 at 00:14 UTC |