- Fixed bugs that were:
[p5sagit/Excel-Template.git] / Makefile.PL
CommitLineData
d0eafc11 1use ExtUtils::MakeMaker;
2# See lib/ExtUtils/MakeMaker.pm for details of how to influence
3# the contents of the Makefile that is written.
a8441e01 4
5use File::Spec;
6
7my $prereqs = {
8 'Test::Simple' => 0.44,
9 'XML::Parser' => 0.01,
10 'IO::File' => 0.01,
37513eae 11 'IO::Scalar' => 0.01,
a8441e01 12 'File::Basename' => 0.01,
13 'Spreadsheet::WriteExcel' => 0.42,
14};
15
16# The assumption is the 5.8.0 and greater doesn't need Unicode::String.
17if ($] < 5.008)
18{
19 print "Do you want Unicode support? ";
20 my $answer = <STDIN>;
21 my $need_unicode = $answer =~ /^[Yy]/;
22
23 my $use_unicode = 0;
24 if ($need_unicode)
25 {
26 $prereqs{'Unicode::String'} = '0.01';
27 $use_unicode = 1;
28 }
29}
30
31use_unicode($use_unicode);
32
d0eafc11 33WriteMakefile(
34 NAME => 'Excel::Template',
35 VERSION_FROM => 'lib/Excel/Template.pm', # finds $VERSION
a8441e01 36 AUTHOR => 'Rob Kinyon (rob.kinyon@gmail.com)',
d0eafc11 37 ABSTRACT => 'Excel::Template',
a8441e01 38 PREREQ_PM => $prereqs,
d0eafc11 39);
a8441e01 40
41sub use_unicode
42{
43 my $using_unicode = shift;
44
45 my @filenames = map {
46 File::Spec->catfile(
47 qw( lib Excel Template ),
48 @{$_},
49 )
50 } ( [ qw( Element Cell.pm_ ) ], [ qw( TextObject.pm_ ) ] );
51
52 foreach my $filename (@filenames)
53 {
54 open(IN_FILE, $filename)
55 or die "Cannot open '$filename' for reading: $!\n";
56 my @lines = <IN_FILE>;
57 close(IN_FILE);
58
59 if ($using_unicode)
60 {
61 for (@lines)
62 {
63 s/^UNI_YES / /;
64 s/^UNI_NO /#/;
65 }
66 }
67 else
68 {
69 for (@lines)
70 {
71 s/^UNI_YES /#/;
72 s/^UNI_NO / /;
73 }
74 }
75
76 $filename =~ s/_$//;
77 open(OUT_FILE, ">$filename")
78 or die "Cannot open '$filename' for writing: $!\n";
79 print OUT_FILE @lines;
80 close(OUT_FILE);
81 }
82
83 return 1;
84}