#!perl use strict; use warnings; &changemyself(); sub changemyself{ my $new_value = 10; my $data=6666666666666; #next time this value will be 10 open (COPIA, ">copia"); open (PROG, "+>>$0"); seek (PROG, 0, 0); #I don't know why but it's NECESSARY! while () { s/^( my .data\s*=\s*)\d+(\s*;)/$1.$new_value.$2/e; print COPIA; } close (PROG); # close (COPIA); # # the terrible imitation # of the open (COPIA, "$0"); # while (){print PROG}# close (PROG); # close (COPIA); # unlink ("copia"); # }