#!/usr/local/bin/perl

use common;

sub DoIt {
}

sub Main {
  local @files;
  my $pattern = ".*_h\.svg"; #shift @ARGV;
  my $dir = "."; #shift @ARGV;
  GetFilesRec($dir, $pattern, \@files);
  open(TEXT, "gradient.xml");
  @TEXTLINES = <TEXT>;
  my $newText = "";
  foreach $line (@TEXTLINES) {
    $newText = "$newText$line";
  }
  close TEXT;
  print $newText;
  
   foreach $f (@files) {
     open(FILE,"$f");
     @LINES = <FILE>;
     close(FILE);
     my $skip = 0;
     open(F,">$f") ;
     foreach $line (@LINES) {
       if ($skip) {
         if ($line =~ /<\/linearGradient>/) {
           $skip = 0;
           print F $newText;
         }
       } elsif ($line =~ /<linearGradient id=.XMLID_1_.*/) {
         $skip = 1;
       } else {
         print F $line;
       }
     }
     close F;
   }
}

&Main;
1;
