--- make_poll.pl 2004/04/13 15:11:58 1.21 +++ make_poll.pl 2004/04/19 16:33:10 1.22 @@ -129,7 +129,33 @@ sub suck_file { my $file = shift || croak "suck_file called without argument"; - open(H,$file) || die "can't open '$file': $!"; + if (! -f $file) { + my $template_file = $file; + $template_file =~ s,^.*?/*([^/]+)$,$1,; + if (-f $template_file) { + print "WARNING: can't find '$file', copy template '$template_file' ? [Y/n]: "; + my $a = ; + chomp $a; + if ($a =~ m/^y/i || $a eq "") { + open(I,$template_file) || die "FATAL: can't open template file '$template_file': $!"; + open(O,"> $file") || die "FATAL: can't create '$file' from template: $!"; + while() { + print O $_; + } + close(I); + close(O); + print "File '$file' created from template '$template_file'\n"; + } + } + + } + + if (! -f $file) { + print STDERR "FATAL: please create file $file and then re-run this script!\n"; + exit 1; + } + + open(H,$file) || die "FATAL: can't open '$file': $!"; my $content; while () { $content .= $_; } ; close(H);