#!/usr/bin/perl 
# -c 1.47  to change the version

use File::Find;
use Getopt::Long;

my $c;
GetOptions ("c=s" => \$c );

check_file( 'script/xpathscript' );

find(\&wanted, 'lib', 'lib_axkit', 'lib_tomkit' );
sub wanted { 
    next unless -f;
    next unless /\.pm$/;

    check_file( $_ );
}

sub check_file {
    my $file = shift;

    open my $fh, '<', $file;
    my @lines = <$fh>;
    close $fh;

    my $version;
    for ( @lines ) {
        if ( $c ) {
            s#(?<=\$VERSION = ')\d+\.\d+([._]\d+)*#$c#
            and
            print ;
        } 

        $version = $1 if m#\$VERSION = '(\d+\.\d+([._]\d+)*)';#;
    }

    if( $c ) {
        open my $fh, '>', $file or die;
        print {$fh} @lines;
        close $fh;
    }

    print "$file - $version\n";
}
