App-FileTools-BulkRename

 view release on metacpan or  search on metacpan

bin/brn  view on Meta::CPAN

# Larry(?)'s RCS header:
#  RCSfile: rename,v   Revision: 4.1   Date: 92/08/07 17:20:30
#
# $RCSfile: rename,v $$Revision: 1.5 $$Date: 1998/12/18 16:16:31 $
#
# $Log: rename,v $
# Revision 1.5  1998/12/18 16:16:31  rmb1
# moved to perl/source
# changed man documentation to POD
#
# Revision 1.4  1997/02/27  17:19:26  rmb1
# corrected usage string
#
# Revision 1.3  1997/02/27  16:39:07  rmb1
# added -v
#
# Revision 1.2  1997/02/27  16:15:40  rmb1
# *** empty log message ***
#
# Revision 1.1  1997/02/27  15:48:51  rmb1
# Initial revision

# Updated Log.
#
# 2010/04/10 - Moved to Git     sti

package main;
use strict;

# use this module BEFORE declaring use utf8, because it isn't.
use Config::IniFiles;

use utf8;
use feature 'unicode_strings';
use open IO => ":encoding(UTF-8)";
binmode STDOUT, ":encoding(UTF-8)";
binmode STDERR, ":encoding(UTF-8)";
binmode STDIN,  ":encoding(UTF-8)";

BEGIN
  { $main::VERSION = substr '$$Version: 0.07 $$', 11, -3; }

use FindBin qw($RealBin);
FindBin::again(); # Other modules can call FindBin too.

use lib "$RealBin/../lib"; # Relative path to our libraries.

use Contextual::Return;
use Encode qw/encode_utf8 decode_utf8/;
use Getopt::Long qw(GetOptionsFromString);
use IO::File;
use List::Util qw(min max);
use Text::ParseWords;

use App::FileTools::BulkRename::Docs qw(usage help manpage readme);
use App::FileTools::BulkRename::Errors;
use App::FileTools::BulkRename::UserCommands;

# for debug only.
use Data::Dump qw(dd pp dump);
use Data::Dumper;
# $Getopt::Long::debug = 1;

Getopt::Long::Configure(qw/bundling permute/);

# preload config options with defaults
my %cfg	=
  ( config    => "$ENV{HOME}/.config/brn.conf"
  , verbosity => 1
  );

# %cfg_in is a hash of (ONLY) options that appeared on the command-line
my %cfg_in;

# Stores global runtime information.
my %data;

sub version
  {
    print "Version: $main::VERSION\n";
    exit BulkRename_Error_Info;
  }

# Closure to control verbosity
sub verbosify
  { my $diff = shift;

    return sub { $cfg{verbosity} += $diff; };
  }

my @optlist;
my @optstk = (\@optlist);

my %optsub =
  ( 'quiet'   => verbosify(-1)
  , 'verbose' => verbosify(+1)
  );

sub record
  { my $optobj = $_[0];
    my $key = $#_ > 1 ? $_[1] : undef;
    my $val = $_[$#_];

    my $ref = $optstk[$#optstk];

    my $opt  = $optobj."";
    my $spec = [ $opt ];

    if( defined $key )
      { push @$spec, $key, $val; }
    else
      { push @$spec, $val if defined $val; }

    push @$ref, $spec;
  }


sub notasuboption
  { my $opt = shift;

    my $msg = $cfg{verbosity} >= 0



( run in 0.567 second using v1.01-cache-2.11-cpan-39bf76dae61 )