my $file = "abc.xml"; open INFO, "$file"; my $count=0; $count++ while ; print Dumper ($count); close INFO; $count=$count-1; $file = "abc.xml"; open INFO, "$file"; my @a=; splice (@a, $count,1); #print Dumper (\@a); close INFO; $file = "abc.xml"; open (INFO, ">$file") or die "cannot open file $@"; print INFO @a; close INFO; $file = "abc.xml"; open INFO, ">>$file"; print INFO $xml1; close INFO; #### my $inp = "abc.xml"; my $out = "new_abc.xml"; open( INP, $inp ) or die "$inp: $!" ); open( OUT, $out ) or die "$out: $!" ); my @array = ; my $xml1 = qq| $date cardev.ebookers $dirn $r |; $array[$#array] = $xml1; # replace last line print OUT join "", @array;