kepler has asked for the wisdom of the Perl Monks concerning the following question:
The problem is that the variable #init_name is always substituted by init_0 (the first value) and doesn't increase. If I put:$ncat += 1; $init_name = "init_$ncat"; open(FILE,">>$filename"); foreach $l(@header){ $l =~ s/#init_name/$init_name/gi; print FILE $l; }
it shows the variable increasing in the print!!! What am I doing wrong? Kind regards, Kepler$ncat += 1; $init_name = "init_$ncat"; open(FILE,">>$filename"); foreach $l(@header){ print #$ncat\n"; $l =~ s/#init_name/$init_name/gi; print FILE $l; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Problem with a replacement
by GrandFather (Saint) on Mar 13, 2011 at 22:36 UTC | |
|
Re: Problem with a replacement
by samarzone (Pilgrim) on Mar 14, 2011 at 09:57 UTC |