in reply to Re: substitution in $0
in thread substitution in $0
In running your code withthe + in it, I have found your regexp does not work as well.open (PROG, "+>>$0");
Output:#!/usr/bin/perl use strict; use warnings; my $new_value = 10; my $data=45; open (PROG, "+>>$0"); seek (PROG, 0, 0); #not working while (<PROG>) { s/^(my .data\s*=\s*)\d+(\s*;)/$1.$new_value.$2/e; print; } close (PROG);
#!/usr/bin/perl use strict; use warnings; my $new_value = 10; my $data=10; open (PROG, "+>>$0"); seek (PROG, 0, 0); #not working while (<PROG>) { s/^(my .data\s*=\s*)\d+(\s*;)/$1.$new_value.$2/e; print; } close (PROG);
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Re: Re: substitution in $0
by Discipulus (Canon) on Oct 03, 2002 at 12:00 UTC | |
by fglock (Vicar) on Oct 03, 2002 at 12:23 UTC |