#! C:\Perl\bin\perl.exe -w use strict; use CGI; use CGI::Carp qw(fatalsToBrowser); use XML::Simple; use File::Copy; my $path = "C:\\web\\policies\\"; my $folder; my($old_file_name, $old_file, $policy_number, $name, $desc, $link_name, $bytesread, $buffer); ############################## # Open xml document and edit # ############################## if ($file) { $link_name = $policy_number . " " . $name . '.doc' } else { $link_name = $old_file } my $xs = new XML::Simple; my $xml = $xs->XMLin("$folder_path\\policies.xml", forcearray => 1, keyattr => ['policies']); foreach my $this (@{$xml->{policies}}) { if ($this->{name} eq $old_file_name) { $this->{link_name} = $link_name; $this->{description} = $desc; $this->{policy_number} = $policy_number; $this->{name} = $name; last; } } $xs->XMLout($xml, outputfile => "$folder_path\\policies.xml", attrindent => 1);