How to replace atom in UnitCell using MaterialsScript???

Hello,everyone.
I am trying replace atoms in UnitCell using MaterialsScript.
For example, 
AgO2 UnitCell have atoms(Ag,Ag,Ag,Ag,O,O)
Replace Ag to Zn, 
ZnO2 UnitCell have atoms(Zn,Zn,Zn,Zn,O,O)

I write this script,,,,

#!perl
use strict;
use Getopt::Long;
use MaterialsScript qw(:all);

my \\\$doc = \\\$Documents{"Ag2O.xsd"};
my \\\$atoms = \\\$doc->UnitCell->Atoms;

foreach my \\\$atom (@\\\$atoms){
print \\\$atom->Name."\\n";
}

I cant understand how to write,,,
I don't have enough knowledge to write it myself, so I would appreciate it if you could write it instead.

Thanks
TK