/[wopi]/make_poll.pl
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /make_poll.pl

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.21 by dpavlin, Tue Apr 13 15:11:58 2004 UTC revision 1.22 by dpavlin, Mon Apr 19 16:33:10 2004 UTC
# Line 129  sub x { Line 129  sub x {
129    
130  sub suck_file {  sub suck_file {
131          my $file = shift || croak "suck_file called without argument";          my $file = shift || croak "suck_file called without argument";
132          open(H,$file) || die "can't open '$file': $!";          if (! -f $file) {
133                    my $template_file = $file;
134                    $template_file =~ s,^.*?/*([^/]+)$,$1,;
135                    if (-f $template_file) {
136                            print "WARNING: can't find '$file', copy template '$template_file' ? [Y/n]: ";
137                            my $a = <STDIN>;
138                            chomp $a;
139                            if ($a =~ m/^y/i || $a eq "") {
140                                    open(I,$template_file) || die "FATAL: can't open template file '$template_file': $!";
141                                    open(O,"> $file") || die "FATAL: can't create '$file' from template: $!";
142                                    while(<I>) {
143                                            print O $_;
144                                    }
145                                    close(I);
146                                    close(O);
147                                    print "File '$file' created from template '$template_file'\n";
148                            }
149                    }
150    
151            }
152    
153            if (! -f $file) {
154                    print STDERR "FATAL: please create file $file and then re-run this script!\n";
155                    exit 1;
156            }
157    
158            open(H,$file) || die "FATAL: can't open '$file': $!";
159          my $content;          my $content;
160          while (<H>) { $content .= $_; } ;          while (<H>) { $content .= $_; } ;
161          close(H);          close(H);

Legend:
Removed from v.1.21  
changed lines
  Added in v.1.22

  ViewVC Help
Powered by ViewVC 1.1.26