inspired by Module Version Number?, this utility will generate the beginnings of a perl script, with use statements for modules passed via command-line, including module versions and null import lists.
for example, saving the script as perlgen.pl, and running with perlgen.pl CGI DBI Win32::Shortcut will produce:
#!/usr/bin/perl require 5.006_001; use strict; use warnings; $|++; ## generated by perlgen.pl: 0.01 use CGI 2.752 qw//; use DBI 1.15 qw//; use Win32::Shortcut 0.03 qw//;
improvements left for the reader
#!/usr/bin/perl require 5.006_001; use strict; use warnings; $|++; our $VERSION = 0.01; ## generate a perl script header ## print generic header print <<"EOH"; #!/usr/bin/perl require 5.006_001; use strict; use warnings; \$|++; ## generated by $0: $VERSION EOH ## print out versions of modules for( @ARGV ) { eval "require $_"; no strict 'refs'; my $modVersion = ${$_ . '::VERSION'} || ''; print "use $_ ", $modVersion, ' qw//;', $/; }
In reply to generate a perl script header by particle
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |