#!/usr/local/bin/perl
(
$server
,
$username
,
$password
,
$schema
,
$fieldname
) =
@ARGV
;
if
(!
defined
(
$password
)) {
print
"usage: $0 [server] [username] [password] [schema] [fieldname]\n"
;
exit
1;
}
print
"Logging in ..\n"
;
(
$ctrl
= ars_Login(
$server
,
$username
,
$password
)) ||
die
"can't login to the server"
;
print
"Fetching field table ..\n"
;
(
%fids
= ars_GetFieldTable(
$ctrl
,
$schema
)) ||
die
"GetFieldTable: $ars_errstr"
;
if
(!
defined
(
$fids
{
$fieldname
})) {
print
"ERROR: I couldn't find a field called \"
$fieldname
\" in the
Default Admin View of schema \
"$schema\"\n"
;
exit
0;
}
print
"Fetching field information ..\n"
;
(
$fieldInfo
= ars_GetField(
$ctrl
,
$schema
,
$fids
{
$fieldname
})) ||
die
"GetField: $ars_errstr"
;
print
"Here are some of the field attributes. More are available.
fieldId:
$fieldInfo
->{fieldId}
createMode:
$fieldInfo
->{createMode}
dataType:
$fieldInfo
->{dataType}
defaultVal:
$fieldInfo
->{defaultVal}
owner:
$fieldInfo
->{owner}
";
dumpKV(
$fieldInfo
, 0);
ars_Logoff(
$ctrl
);
exit
0;
sub
dumpKV {
my
$hr
=
shift
;
my
$i
=
shift
;
foreach
$k
(
keys
%$hr
){
print
"\t"
x
$i
.
"key=<$k> val=<$hr->{$k}>\n"
;
if
(
ref
(
$hr
->{
$k
}) eq
"HASH"
) {
dumpKV(
$hr
->{
$k
},
$i
+1);
}
elsif
(
ref
(
$hr
->{
$k
}) eq
"ARRAY"
) {
dumpAV(
$hr
->{
$k
},
$i
+1);
}
}
}
sub
dumpAV {
my
$ar
=
shift
;
my
$i
=
shift
;
my
$a
= 0;
foreach
(
@$ar
) {
print
"\t"
x
$i
.
"index=<$a> val=<$_>\n"
;
if
(
ref
(
$_
) eq
"HASH"
) {
dumpKV(
$_
,
$i
+1);
}
elsif
(
ref
(
$_
) eq
"ARRAY"
) {
dumpAV(
$_
,
$i
+1);
}
$a
++;
}
}