Hello dear PERL MONKS!
I am new to PERL, and i tryed to create a programm, which searches all FILES in the same directory as the programm is placed FOR a word that i type in and REPLACES it for NEXT WORD that i also type in ...
EXAMPLE: I hit start, it asks what word shall be replaced? I type in GIF. Which word shall be there in stead o GIF? I type in IMG. I hit ENTER and it shall search the whole directory for the word GIF and replace it with IMG.
My programm, which i made works on the same way, but it has some disadvantages. It does not SEARCH - i have no idea how to make it, i have to write always the name of the file which i want to be edited ... I tryed Tutorials but they did not help ... And the second disadvantage is, that it waork only with the first line of my TEXT FILE .. I also have no idea why ...
Could you please help me solve this two problems? Here is my source:
use warnings; system"cls"; print "Which TEXT File shall be changhed?\n"; my $datname = <STDIN>; chomp($datname); open(READFILE,"<$datname"); my $erssetz = <READFILE>; close(READFILE); print "\n"; my $vor = $erssetz; print "Which word you want to be REPLACED? \n"; my $wort = <STDIN>; chomp($wort); print "\n"; print "What word shall be there the REPLACER? \n"; my $ersetz = <STDIN>; chomp($ersetz); print "\n"; $erssetz =~ s/$wort/$ersetz/g; open(WRITEFILE,">Ersetzt_$datname"); print WRITEFILE $erssetz; close(WRITEFILE); print "Finished -> saved AS : REPLACED_$datname \n";
In reply to Word Replacing by xoddam
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |