|
#!/usr/local/bin/perl
#------------------------------------------------------------------------------#
package JARRAY;
#------------------------------------------------------------------------------#
sub new {
my ($class, @data) = @_;
my $ref = [];
bless $ref, $class;
if( @data ) { $ref->add(@data); }
return $ref;
}
sub add { my ($ref, @data) = @_; push(@$ref,@data); }
sub list { my ($ref) = @_; return (@$ref); }
sub print_list {
my ($ref,$tab) = @_;
$tab2 = $tab." ";
print "$tab$ref = (";
foreach $alist ( @$ref ) {
if( ref($alist) eq "SCALAR" ) {
print "$alist ";
}
elsif( ref($alist) eq "HASH" ) {
jhash::print_list($alist,$tab2);
}
elsif( ref($alist) eq "ARRAY" ) {
&print_list($alist,$tab2);
}
else { $alist->print_list($tab2); }
}
print "$tab)\n";
}
sub print_list_hash { my ($ref,$tab) = @_; }
#------------------------------------------------------------------------------#
package JHASH;
#------------------------------------------------------------------------------#
sub new {
my ($class, @data) = @_;
my $ref = {};
bless $ref, $class;
$ref->add(@data);
return $ref;
}
sub add {
my ($ref, @data) = @_;
%$ref = (%$ref,@data);
}
sub print_list {
my ($ref,$tab) = @_;
$tab2 = $tab." ";
print "$tab$ref = (\n";
foreach $key (keys %$ref) {
print "$tab2$key=>";
jarray::print_list(%$ref->{$key},$tab);
print "\n";
}
print "$tab)\n";
}
1;
|
|