Ansible
view release on metacpan or search on metacpan
lib/Ansible.pm view on Meta::CPAN
@EXPORT_OK = qw( readconfig stringconfig $minus_one_indent_rx );
$VERSION = '0.101';
require Exporter;
use strict;
use Text::Tabs;
use Carp;
use Carp qw( verbose confess );
use IO::File;
use Scalar::Util qw( weaken );
my $iostrings;
our $allow_minus_one_indent = qr/class /;
our $allow_plus_one_indent = qr/service-policy |quit$/;
our $bad_indent_policy = 'DIE';
BEGIN {
eval " use IO::String ";
$iostrings = $@ ? 0 : 1;
}
lib/Ansible.pm view on Meta::CPAN
$line = <$fh>;
return rc1(0, 'aaaa', $undef, "! whole enchalada\n");
}
sub rc1 {
my ($indent, $seq, $parent, $dcon) = @_;
my $config = bless { $bloc => 1 }, __PACKAGE__;
$config->{$debg} = "BLOCK:$dseq:$dcon" if $ddata;
$config->{$cntx} = $parent;
weaken $config->{$cntx};
$dseq ++;
my ($last, $prev, $ciscobug);
for ( ; $line; $prev = $line, $line = <$fh> ) {
$_ = $line;
s/^( *)//;
my $in = length($1);
s/^(no +)//;
#æ°è¡åå³ç¼©è¿
if ( $in > $indent ) {
lib/Ansible.pm view on Meta::CPAN
$word => $x,)
: (),
}, __PACKAGE__;
$dseq ++;
}
$context->{$seqn} = $seq ++;
$context->{$text} = $line;
confess if $context->{$cntx};
$context->{$cntx} = $config;
weaken $context->{$cntx};
unless ( $nonext ) {
if ( $last ) {
$last->{$next} = $context;
weaken $last->{$next};
}
else {
$config->{$next} = $context;
weaken $config->{$next};
}
}
$last = $context;
if ( $line &&
($line =~ /(\^C)/ && $line !~ /\^C.*\^C/)
||
($line =~ /banner [a-z\-]+ ((?!\^C).+)/) ) {
#
# big special case for banners 'cause they don't follow
# normal indenting rules
#
die unless defined $1;
my $sep = qr/\Q$1\E/;
my $sub = $last->{$subs} = bless { $bloc => 1 }, __PACKAGE__;
$sub->{$cntx} = $last;
weaken $sub->{$cntx};
my $subnull = $sub->{''} = bless { $bloc => 1, $dupl => [] }, __PACKAGE__;
$subnull->{$cntx} = $sub;
weaken $subnull->{$cntx};
for ( ;; ) {
$line = <$fh>;
last unless $line;
my $l = bless {
$ddata ? ($debg => "$dseq:DUP:$line") : (),
}, __PACKAGE__;
$dseq ++;
$l->{$seqn} = $seq ++;
$l->{$text} = $line;
$l->{$cntx} = $subnull;
weaken($l->{$cntx});
push(@{ $subnull->{$dupl} }, $l);
last if $line =~ /$sep[\r]?$/;
}
warn "parse probably failed"
unless $line && $line =~ /$sep[\r]?$/;
}
}
return $config;
}
( run in 0.260 second using v1.01-cache-2.11-cpan-65fba6d93b7 )