-
Notifications
You must be signed in to change notification settings - Fork 0
/
combine_two_svg.pl
69 lines (47 loc) · 1.25 KB
/
combine_two_svg.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/usr/bin/perl
=head1 Name
combine two svg files
=head1 Description
=head1 Version
Author: Fan Wei, [email protected]
Version: 1.0, Date: 2006-12-6
Note:
=head1 Usage
--verbose output running progress information to screen
--help output help information to screen
=head1 Exmple
=cut
use strict;
use Getopt::Long;
use FindBin qw($Bin $Script);
use File::Basename qw(basename dirname);
use Data::Dumper;
use File::Path; ## function " mkpath" and "rmtree" deal with directory
##get options from command line into variables and set default values
my ($Verbose,$Help);
GetOptions(
"verbose"=>\$Verbose,
"help"=>\$Help
);
die `pod2text $0` if (@ARGV == 0 || $Help);
my $svg_file1 = shift;
my $svg_file2 = shift;
my ($content1,$content2);
$content1 = read_file($svg_file1);
$content2 = read_file($svg_file2);
$content1 =~ s/<\/svg>\s*$//;
$content2 =~ s/<\?xml.+?\n<\!DOCTYPE.+?\n<svg height.+?\n//;
print $content1.$content2;
####################################################
################### Sub Routines ###################
####################################################
sub read_file {
my $file = shift;
my $content;
open IN,$file || die "fail";
while (<IN>) {
$content .= $_;
}
close IN;
return $content;
}