X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=Makefile.PL;h=6fdd34a9e1285660beb18918a987c732da94072a;hb=a8441e01145a643b71fb562b00a0b02cf82eb61c;hp=89504ef57b3f4e5393e270b368d6db2a5890460a;hpb=d0eafc11b999be05367693c7d16879a83d3f2d19;p=p5sagit%2FExcel-Template.git diff --git a/Makefile.PL b/Makefile.PL index 89504ef..6fdd34a 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -1,16 +1,83 @@ use ExtUtils::MakeMaker; # See lib/ExtUtils/MakeMaker.pm for details of how to influence # the contents of the Makefile that is written. + +use File::Spec; + +my $prereqs = { + 'Test::Simple' => 0.44, + 'XML::Parser' => 0.01, + 'IO::File' => 0.01, + 'File::Basename' => 0.01, + 'Spreadsheet::WriteExcel' => 0.42, +}; + +# The assumption is the 5.8.0 and greater doesn't need Unicode::String. +if ($] < 5.008) +{ + print "Do you want Unicode support? "; + my $answer = ; + my $need_unicode = $answer =~ /^[Yy]/; + + my $use_unicode = 0; + if ($need_unicode) + { + $prereqs{'Unicode::String'} = '0.01'; + $use_unicode = 1; + } +} + +use_unicode($use_unicode); + WriteMakefile( NAME => 'Excel::Template', VERSION_FROM => 'lib/Excel/Template.pm', # finds $VERSION - AUTHOR => 'Rob Kinyon (rkinyon@columbus.rr.com', + AUTHOR => 'Rob Kinyon (rob.kinyon@gmail.com)', ABSTRACT => 'Excel::Template', - PREREQ_PM => { - 'Test::Simple' => 0.44, - 'Spreadsheet::WriteExcel' => 0.42, - 'XML::Parser' => 0.01, - 'IO::Scalar' => 0.01, - 'IO::File' => 0.01, - }, + PREREQ_PM => $prereqs, ); + +sub use_unicode +{ + my $using_unicode = shift; + + my @filenames = map { + File::Spec->catfile( + qw( lib Excel Template ), + @{$_}, + ) + } ( [ qw( Element Cell.pm_ ) ], [ qw( TextObject.pm_ ) ] ); + + foreach my $filename (@filenames) + { + open(IN_FILE, $filename) + or die "Cannot open '$filename' for reading: $!\n"; + my @lines = ; + close(IN_FILE); + + if ($using_unicode) + { + for (@lines) + { + s/^UNI_YES / /; + s/^UNI_NO /#/; + } + } + else + { + for (@lines) + { + s/^UNI_YES /#/; + s/^UNI_NO / /; + } + } + + $filename =~ s/_$//; + open(OUT_FILE, ">$filename") + or die "Cannot open '$filename' for writing: $!\n"; + print OUT_FILE @lines; + close(OUT_FILE); + } + + return 1; +}