Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

generate a perl script header

by particle (Vicar)
on Nov 02, 2002 at 15:08 UTC ( [id://209954]=CUFP: print w/replies, xml ) Need Help??

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//;', $/; }

Replies are listed 'Best First'.
Re: generate a perl script header
by jdavidboyd (Friar) on Nov 04, 2002 at 14:00 UTC
    When I run it I get:

    Use of uninitialized value in print at ./gen_perl_script_header.plx line 28.

    Dave

      whoops! it seems if the module doesn't have a $VERSION variable, you'll run into this problem. i've patched the code to get around this limitation.

      ~Particle *accelerates*

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: CUFP [id://209954]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (6)
As of 2024-03-29 14:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found