3 eval 'exec /usr/bin/perl -w -S $0 ${1+"$@"}'
4 if 0; # not running under some shell
20 getopts
('n',\
%opt) or pod2usage
(1);
22 @ARGV == 2 or pod2usage
(1);
24 my ($tname,$newfile) = @ARGV;
25 my $tgtpath = dirname
($newfile);
27 my ($sgn_tools_location) = $FindBin::RealBin
=~ m!(^.+/sgn-devtools)(/|$)!;
28 $sgn_tools_location && -d
$sgn_tools_location
29 or die "could not figure out sgn-devtools installed location";
31 my @templatematches = ( glob("~/{T,t}emplates/$tname*"),
32 glob("$sgn_tools_location/development/templates/$tname*"),
33 glob("$FindBin::RealBin/templates/$tname*"),
35 or die "No template found matching '$tname";
37 @templatematches = grep !/~$/,@templatematches; #filter out backup files
39 or die "More than one template matches '$tname':\n",map {" - $_\n"} @templatematches;
41 my ($template) = @templatematches;
43 #add an extension to the target file if it doesn't have one
44 my (undef,undef,$ext) = fileparse
($template,qr/\..+$/);
45 $newfile .= $ext unless $newfile =~ /$ext$/;
49 or mkpath
( $tgtpath, {verbose
=> 1})
50 or die "could not create dir '$tgtpath'";
52 #copy the template file there
53 system( cp
=> -aH
=> $template => $newfile );
54 $CHILD_ERROR and die "Could not copy template from $template to $newfile: $!";
59 if( $template =~ /\.od[pfts]$|\.sx[iwc]$|\.doc$|\.xls$|\.ppt$/ ) {
60 exec 'ooffice', $newfile;
62 #scripts or other things
64 $ENV{EDITOR
} or die "No \$EDITOR environment variable defined, please make sure it's in your .bashrc or similar\n";
72 new_sgn_file - script to create new SGN files from templates
76 new_sgn_file [options] template_name new_filename
80 -n if passed, do not open $EDITOR after making file
84 Robert Buels, Jonathan "Duke" Leto
88 Robert Buels, E<lt>rmb32@cornell.eduE<gt>
90 =head1 COPYRIGHT & LICENSE
92 Copyright 2009 Boyce Thompson Institute for Plant Research
94 This program is free software; you can redistribute it and/or modify
95 it under the same terms as Perl itself.