Heray-Was-Here
Server : Apache
System : Linux vps43555.mylogin.co 3.10.0-1160.53.1.vz7.185.3 #1 SMP Tue Jan 25 12:49:12 MSK 2022 x86_64
User : redsea ( 60651)
PHP Version : 7.4.32
Disable Function : NONE
Directory :  /usr/local/share/perl5/XML/SimpleObject/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //usr/local/share/perl5/XML/SimpleObject/Enhanced.pm
package XML::SimpleObject::Enhanced;

use strict;
use warnings;
our $VERSION = '0.53';

use XML::SimpleObject 0.53;
our @ISA = qw(XML::SimpleObject);

my $shiftwidth = 2;

sub _space($)
{
    my $offset = shift || 0;
    return " " x ($offset * $shiftwidth);
}

sub output($;$);

sub output($;$)
{
    my $self = shift;
    my $indent = shift || 0;
    my %attribs = $self->attributes;
    my $xml = _space($indent) . "<" . $self->name;
    $xml .= " $_=\"" . $attribs{$_} . '"' foreach (keys %attribs);
    my @data = split /\n/, $self->value;
    my ($nl, $in, $in1);
    if (@data > 1)
    {
	$nl = "\n";
	$in = _space($indent);
	$in1 = _space($indent + 1);
    }
    else {
	$nl = $in = $in1 = '';
    }
    $xml .= ">$nl";
    $xml .= $in1 . "$_$nl" foreach (grep s/^\s*(\S.*?)\s*/$1/, @data);
    $xml .= output($_, $indent + 1) foreach $self->children;
    $xml .=  $in . "</" . $self->name. ">\n";
    return $xml;
}

sub append
{
    my $self = shift;
    while (my $new = shift)
    {
	my @array = ($new);
	$self->{$new->{_NAME}} = \@array;
    }
}

1;

Hry