/[webpac]/trunk2/import_xml/migration_to_v2.pl
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Annotation of /trunk2/import_xml/migration_to_v2.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 364 - (hide annotations)
Wed Jun 16 23:09:02 2004 UTC (16 years, 7 months ago) by dpavlin
File MIME type: text/plain
File size: 741 byte(s)
migration script from WebPAC v1.x field format (in format 999a) to
new format, more ISIS like, and used by eval v999^a

1 dpavlin 364 #!/usr/bin/perl -w
2    
3     use strict;
4    
5     foreach my $file (@ARGV) {
6    
7     open(XML,$file) || die "can't open '$file': $!";
8    
9     my $xml;
10     while (<XML>) {
11     $xml .= $_;
12     }
13    
14     close(XML);
15    
16     my $new_xml;
17    
18     sub to_v {
19     my ($f,$sf) = @_;
20     my $out = "v".$f;
21     $out .= "^".$sf if ($sf);
22     return $out;
23     }
24    
25     while ($xml =~ s/(^.+?<isis[^>]*>)(.+?)(<\/isis>)//s) {
26     my ($pre,$data,$post) = ($1,$2,$3);
27     $data =~ s/(\d{3})([\w\d]?)/to_v($1,$2)/esg;
28     $data =~ s/v(v\d{3}\^\w)/$1/gs;
29     $new_xml .= $pre.$data.$post;
30     }
31     $new_xml .= $xml;
32    
33     open(XML,"> $file-new") || die "can't create '$file-new': $!";
34     print XML $new_xml;
35     close(XML);
36    
37     rename "$file-new","$file" || die "can't update original file '$file' with '$file-new': $!";
38    
39     print "$file converted\n";
40     }
41    

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.26