open(X,">$time.pl") or die "$!"; print X $child; close(X); #### system "perl $time.pl"; #### print "Location: $parent_url?d=1\n\n"; #### unlink "$time.pl"; #### #!perl -w use strict; use CGI qw(:standard); my$url = url(-relative=>1); my$time=time(); my$d = param('d'); if($d eq '1'){&show;exit} eval("seek DATA,0,0;"); undef$/; $_=; # read self into $_ $_ =~ m/__END__\n(\d.*)/; my$num=$1; $num++; # find target in $_ and change # build child script with $url and $num (to open, change, save, and run parent) my$child = "#!perl -w\n\nuse CGI qw(:standard);\nopen(Z,\"+>>$url\") or die \"\$!\";\nundef\$/;\n\$_=;\n\$_=~s|__END__\\n(\\d.*)|__END__\\n$num|o;\nseek Z, 0, 0;\ntruncate Z, 0;\nprint Z \$_;\nclose(Z);\nprint \"Location: $url?d=1\\n\\n\";"; open(X,">$time.pl") or die "$!"; # create and print X $child; close(X); # print and close system "perl $time.pl"; # and run and unlink "$time.pl"; # delete child sub show{ print header,start_html(-title=>'polymorphic perl',-bgcolor=>'#000000'); while(){ print qq~$_~}} exit; __END__ 0 #### #!perl -w use CGI qw(:standard); open(Z,"+>>pp.pl") or die "$!"; undef$/; $_=; $_=~s|__END__\n(\d.*)|__END__\n8|o; seek Z, 0, 0; truncate Z, 0; print Z $_; close(Z); print "Location: pp.pl?d=1\n\n";