Hi ,
I'am trying to update a text file. But somehow it does not work. I gets the following error:
Can't "next" outside a block at PersonalfrmList.pl
Here a snippet of my code:
open(IN,"c:\\h\\CSSCS\\bin\scripts\\ListofFile.txt"|| die "Can't open ListofFile.txt for update:$!\n";
@lines =<IN>;
close IN;
my $change_count = 0;
@lines = map {$change_count++ if s/"cat"/"dog"/sgi; $_ } @lines;
next unless $change_count;
open(OUT,">c:\\h\\CSSCS\\bin\\scripts\\ListofFile.txt" || "can't open file for writing: $!\n";
print OUT @lines;
close OUT;
Can anyone tells me what I did wrong?
-thanks kirk124
I'am trying to update a text file. But somehow it does not work. I gets the following error:
Can't "next" outside a block at PersonalfrmList.pl
Here a snippet of my code:
open(IN,"c:\\h\\CSSCS\\bin\scripts\\ListofFile.txt"|| die "Can't open ListofFile.txt for update:$!\n";
@lines =<IN>;
close IN;
my $change_count = 0;
@lines = map {$change_count++ if s/"cat"/"dog"/sgi; $_ } @lines;
next unless $change_count;
open(OUT,">c:\\h\\CSSCS\\bin\\scripts\\ListofFile.txt" || "can't open file for writing: $!\n";
print OUT @lines;
close OUT;
Can anyone tells me what I did wrong?
-thanks kirk124