use AutoLoader
'AUTOLOAD';
my ($comma) = $o->{comma
};
$package = caller(1) if $package eq 'Inline::denter';
@
{$o->{lines
}} = split $/, $text;
$o->{content
} =~ /^(\w+)\s*$comma\s*(.*)$/) {
push @
{$o->{objects
}}, "$1";
push @
{$o->{objects
}}, $o->_undent_data;
my ($obj, $class) = ('', '');
while ($o->{content
} =~ s/^\\(?:\((\w+)\))?((\%|\@|\$|\\).*)/$2/) {
$refs{$1} = scalar @refs;
if ($o->{content
} =~ /^([\
%\@\
$])
$obj = ($1 eq '%') ?
{} : ($1 eq '@') ?
[] : \
$foo;
%$obj = $o->_undent_hash;
@
$obj = $o->_undent_array;
$$obj = $o->_undent_scalar;
bless $obj, $class if length $class;
elsif ($o->{content
} =~ /^\?\s*$/) {
$obj = $o->_undent_undef;
$obj = $o->_undent_value;
$o->{xref
}{$ref} = $obj if $ref;
if ($o->{content
} =~ /^\<\<(\w+)(\-?)\s*$/) {
my ($marker, $chomp) = ($1, $2);
while (not $o->{done
} and
$o->{lines
}[0] ne $marker) {
$value .= $o->{lines
}[0] . "\n";
croak M03_no_value_end_marker
($marker, $line) if $o->{done
};
elsif ($o->{content
} =~ /^\"/) {
croak
$o->M04_mismatched_quotes unless $o->{content
} =~ /^\".*\"\s*$/;
($value = $o->{content
}) =~ s/^\"|\"\s*$//g;
my $level = $o->{level
} + 1;
while ($o->{level
} == $level) {
my ($key, $value) = split $o->{comma
}, $o->{content
};
croak
$o->M05_invalid_key_value unless (defined $key and defined $value);
push @values, $o->_get_key($key), $o->_undent_data;;
croak
$o->M06_invalid_indent_level if $o->{level
} > $level;
return $key unless $key =~ /^\<\<(\w+)(\-?)/;
my ($marker, $chomp) = ($1, $2);
while (not $o->{done
} and
$o->{lines
}[0] ne $marker) {
$key .= $o->{lines
}[0] . "\n";
croak M02_no_key_end_marker
($marker, $line) if $o->{done
};
my $level = $o->{level
} + 1;
while ($o->{level
} == $level) {
push @values, $o->_undent_data;
croak
$o->M06_invalid_indent_level if $o->{level
} > $level;
my $level = $o->{level
} + 1;
croak
$o->M06_invalid_indent_level if $o->{level
} != $level;
croak
$o->M07_invalid_scalar_value if $o->{content
} =~ /^[\%\@\$\\]/;
return $o->_undent_undef if $o->{content
} =~ /^\?/;
return $o->_undent_value;
$o->{done
}++, $o->{level
} = -1, return unless @
{$o->{lines
}};
$_ = shift @
{$o->{lines
}};
$o->{done
}++, $o->{level
} = -1, return unless @
{$o->{lines
}};
my ($width, $tabwidth) = @
{$o}{qw(width tabwidth)};
# expand tabs in leading whitespace;
$o->next_line, next if /^(\s*$|\#)/; # skip comments and blank lines
{' ' x
(length($1) + length($2) * $tabwidth -
length($1) % $tabwidth)}e
){}
croak
$o->M01_invalid_indent_width unless /^(( {$width})*)(\S.*)$/;
$o->{level
} = length($1) / $width;
$package = caller(1) if $package eq 'Inline::denter';
$stream .= $o->indent_name($_, shift), next
if (/^\*$package\::\w+$/);
$stream .= $o->indent_data($_);
return $o->indent_undef($_)
return $o->indent_value($_)
return $o->indent_hash($_)
if (ref eq 'HASH' and not /=/ or /=HASH/);
return $o->indent_array($_)
if (ref eq 'ARRAY' and not /=/ or /=ARRAY/);
return $o->indent_scalar($_)
if (ref eq 'SCALAR' and not /=/ or /=SCALAR/);
return $o->indent_ref($_)
$marker++ while $data =~ /^$marker$/m;
my $chomp = ($data =~ s/\n\Z//) ?
'' : '-';
$stream = "<<$marker$chomp\n";
$stream .= $o->{key
}, $o->{key
} = '' if $o->{key
};
$stream .= "$data\n$marker\n";
elsif ($data =~ /^[\s\%\@\$\\?\"]|\s$/ or
$data =~ /\Q$o->{comma}\E/ or
$data =~ /[\x00-\x1f]/ or
$stream .= $o->{key
}, $o->{key
} = '' if $o->{key
};
$stream .= $o->{key
}, $o->{key
} = '' if $o->{key
};
my $stream = $o->_print_ref($data, '%', 'HASH');
return $$stream if ref $stream;
my $indent = ++$o->{level
} * $o->{width
};
for my $key (sort keys %$data) {
$key =~ /\Q$o->{comma}\E/) {
$marker++ while $key =~ /^$marker$/m;
my $chomp = (($o->{key
} = $key) =~ s/\n\Z//m) ?
'' : '-';
$o->{key
} .= "\n$marker\n";
$key_out = "<<$marker$chomp";
elsif ($data =~ /^[\s\%\@\$\\?\"]|\s$/) {
$stream .= ' ' x
$indent . $key_out . $o->{comma
};
$stream .= $o->indent_data($data->{$key});
my $stream = $o->_print_ref($data, '@', 'ARRAY');
return $$stream if ref $stream;
my $indent = ++$o->{level
} * $o->{width
};
$stream .= ' ' x
$indent;
$stream .= $o->indent_data($datum);
my $stream = $o->_print_ref($data, q{$}, 'SCALAR');
return $$stream if ref $stream;
my $indent = ($o->{level
} + 1) * $o->{width
};
$stream .= ' ' x
$indent;
$stream .= $o->indent_data($$data);
my $stream = $o->_print_ref($data, '\\', 'SCALAR');
return $$stream if ref $stream;
return $stream . $o->indent_data($$data);
$stream .= $o->{key
}, $o->{key
} = '' if $o->{key
};
my ($o, $name, $value) = @_;
my $stream = $name . $o->{comma
};
$stream .= $o->indent_data($value);
my ($o, $data, $symbol, $type) = @_;
$data =~ /^(([\w:]+)=)?$type\(0x([0-9a-f]+)\)$/
or croak
"Invalid reference: $data\n";
$stream .= $2 if defined $2;
croak
"Inline::denter does not handle duplicate references"
$stream .= $o->{key
}, $o->{key
} = '' if $o->{key
};
sub M01_invalid_indent_width
{
"Invalid indent width detected at line $o->{line}\n";
sub M02_no_key_end_marker
{
my ($marker, $line) = @_;
"No terminating marker '$marker' found for key at line $line\n";
sub M03_no_value_end_marker
{
my ($marker, $line) = @_;
"No terminating marker '$marker' found for value at line $line\n";
sub M04_mismatched_quotes
{
"Mismatched double quotes for value at line $o->{line}\n";
sub M05_invalid_key_value
{
"Missing or invalid hash key/value pair at $o->{line}\n";
sub M06_invalid_indent_level
{
"Invalid indentation level at $o->{line}\n";
sub M07_invalid_scalar_value
{
"Invalid value for scalar ref context at $o->{line}\n";