Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

Re^4: Trying to build a module for upload to CPAN

by cavac (Priest)
on Oct 29, 2021 at 09:54 UTC ( #11138194=note: print w/replies, xml ) Need Help??

in reply to Re^3: Trying to build a module for upload to CPAN
in thread Trying to build a module for upload to CPAN

For me, updating the manifest is pretty much standard procedure whenever i add or remove files from one of my projects. As for updating version numbers and stuff, i also have scripts for that.

#!/usr/bin/env perl #---AUTOPRAGMASTART--- use 5.020; use strict; use warnings; use diagnostics; use mro 'c3'; use English; use Carp; our $VERSION = 18; use autodie qw( close ); use Array::Contains; use utf8; use Encode qw(is_utf8 encode_utf8 decode_utf8); #---AUTOPRAGMAEND--- # PAGECAMEL (C) 2008-2020 Rene Schickbauer # Developed under Artistic license my $newversion = shift @ARGV || "???"; if($newversion eq "???") { print "Usage: perl devscripts/ 9.87\n"; exit(0); } print "Searching files...\n"; my @files = (find_pm('lib'), find_pm('devscripts'), find_pm('example') +); print "Changing files:\n"; foreach my $file (@files) { print "Editing $file...\n"; my @lines; open(my $ifh, "<", $file) or die($ERRNO); @lines = <$ifh>; close $ifh; open(my $ofh, ">", $file) or die($ERRNO); foreach my $line (@lines) { $line =~ s/VERSION = [\d\.]+/VERSION = $newversion/g; print $ofh $line; } close $ofh; } print "Done.\n"; exit(0); sub find_pm { my ($workDir) = @_; my @files; opendir(my $dfh, $workDir) or die($ERRNO); while((my $fname = readdir($dfh))) { next if($fname eq "." || $fname eq ".." || $fname eq ".hg"); $fname = $workDir . "/" . $fname; if(-d $fname) { push @files, find_pm($fname); } elsif($fname =~ /\.p[lm]$/i && -f $fname) { push @files, $fname; } } closedir($dfh); return @files; }

It's probably not the most efficient of scripts, but it does the job for me in a lot of open source and closed source projects. This one is taken directly from my Net::Clacks repository. The script is in the "devscripts" directory, which also holds such gems as "" that allows me to change the standard pragmas for all *.pm files in a project all in one go.

perl -e 'use Crypt::Digest::SHA256 qw[sha256_hex]; print substr(sha256_hex("the Answer To Life, The Universe And Everything"), 6, 2), "\n";'

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (2)
As of 2022-08-17 16:56 GMT
Find Nodes?
    Voting Booth?

    No recent polls found