Text-MetaText

 view release on metacpan or  search on metacpan

bin/metapage  view on Meta::CPAN

#!/usr/bin/perl -w
#========================================================================
#
# metapage
#
# DESCRIPTION
#   Script for automating batch processing of files using the MetaText 
#   module.  Configuration files are used to specify MetaText options 
#   and pre-defined substitutions, as well as indicating the source and 
#   destination directories for input/output files.  Generally useful for 
#   processing entire directory trees of source files using a similar 
#   template.
#
# AUTHOR
#   Andy Wardley <abw@kfs.org>
#
# COPYRIGHT
#   Copyright (C) 1996-1998 Andy Wardley.  All Rights Reserved.
#   
#   This script is free software; you can redistribute it and/or
#   modify it under the terms of the Perl Artistic Licence.
#
#------------------------------------------------------------------------
#
# $Id: metapage,v 1.11 1998/04/02 09:05:36 abw Exp abw $
#
#========================================================================

require 5.004;

use strict;
use Text::MetaText;
use File::Recurse;


my $NAME     = "metapage";
my $VERSION  = sprintf("%d.%02d", q$Revision: 1.11 $ =~ /(\d+)\.(\d+)/);
my $HOME     = $ENV{ HOME } || (getpwuid($<))[7] || die "No HOME\n";
my $RCFILE   = $ENV{"\U${NAME}rc"} || "$HOME/.${NAME}rc";

# configuration items
my %mppath   = ();
my %mtcfg    = (); 
my %mtdef    = ();
my @cfgfiles = ();
my @casevars = qw(FILENAME FILEPATH FULLPATH FILETIME FILEMOD);

# cmd line flags
my ($verbose, $quiet, $debug, $force, $recurse, $today, $all, $noexec) 
    = (0) x 8;

# src/dest file and path names 
my ($path, $file, $srcfile, $destfile);

# file process/skip table
my $filelist = { 
    NOT_FOUND    => [],
    NOT_ACCEPTED => [],
    NOT_MODIFIED => [],
    IGNORED      => [],
    PROCESS      => [],
};

# process/skip stats.  $queued is for non-execute mode (-n)
my ($processed, $skipped, $failed, $queued) = (0) x 4;



#========================================================================
#
# process command line, .rc and config files 
#
#========================================================================

# pull all "@config" file parameters into @cfgfiles...
@cfgfiles = grep { /^@(.*)/ } @ARGV;

# ...and remove leading '@'
foreach (@cfgfiles) {
    s/^@//;
}

# check all command line -opts
foreach ( map{ /^-(.*)/ ? split('', $1) : () } @ARGV) {

	/^-$/    && last;
	/^h$/    && do { usage();                  exit };
	/^v$/    && do { $verbose++;               next };
	/^q$/    && do { $quiet++;                 next };
	/^d$/    && do { $debug++;                 next };
	/^f$/    && do { $force++;                 next };
	/^m$/    && do { $today = 0;               next };
	/^t$/    && do { $today = 1;               next };
	/^n$/    && do { $noexec = 1; $verbose++;  next };
	/^a$/    && do { $all++; $recurse++;       next };
	/^[Rr]$/ && do { $recurse++;               next };

	warn "Invalid option: $_\n";



( run in 0.616 second using v1.01-cache-2.11-cpan-e1769b4cff6 )