- Converted to use Unicode logic from PDF::Template
Rob Kinyon [Wed, 27 Oct 2004 17:36:39 +0000 (17:36 +0000)]
- Added mailing list and new email address to POD

Makefile.PL
lib/Excel/Template.pm
lib/Excel/Template/Element/Cell.pm_ [moved from lib/Excel/Template/Element/Cell.pm with 97% similarity, mode: 0755]
lib/Excel/Template/TextObject.pm_ [moved from lib/Excel/Template/TextObject.pm with 85% similarity, mode: 0755]

index 89504ef..6fdd34a 100644 (file)
@@ -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 = <STDIN>;
+    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 = <IN_FILE>;
+        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;
+}
index 665405b..b5780af 100644 (file)
@@ -341,7 +341,11 @@ but I expect to be adding on to it very soon.
 =head1 AUTHOR
 
     Rob Kinyon
-    rkinyon@columbus.rr.com
+    rob.kinyon@gmail.com
+
+=head1 CONTRIBUTORS
+
+There is a mailing list at http://groups-beta.google.com/group/ExcelTemplate
 
 =head1 COPYRIGHT
 
old mode 100644 (file)
new mode 100755 (executable)
similarity index 97%
rename from lib/Excel/Template/Element/Cell.pm
rename to lib/Excel/Template/Element/Cell.pm_
index 88a0140..6db119c
@@ -37,8 +37,8 @@ sub get_text
     }
     else
     {
-#        $txt = Unicode::String::utf8('');
-        $txt = '';
+UNI_YES        $txt = Unicode::String::utf8('');
+UNI_NO         $txt = '';
     }
                                                                                 
     return $txt;
old mode 100644 (file)
new mode 100755 (executable)
similarity index 85%
rename from lib/Excel/Template/TextObject.pm
rename to lib/Excel/Template/TextObject.pm_
index ac7a3d7..3597af5
@@ -8,7 +8,7 @@ BEGIN {
 
     use Excel::Template::Base;
 
-#    use Unicode::String;
+UNI_YES     use Unicode::String;
 }
 
 # This is a helper object. It is not instantiated by the user,
@@ -31,8 +31,8 @@ sub resolve
     my $self = shift;
     my ($context) = @_;
 
-#    my $t = Unicode::String::utf8('');
-    my $t = '';
+UNI_YES    my $t = Unicode::String::utf8('');
+UNI_NO    my $t = '';
 
     for my $tok (@{$self->{STACK}})
     {
@@ -40,8 +40,8 @@ sub resolve
         $val = $val->resolve($context)
             if Excel::Template::Factory::isa($val, 'VAR');
 
-#        $t .= Unicode::String::utf8("$val");
-        $t .= $val;
+UNI_YES        $t .= Unicode::String::utf8("$val");
+UNI_NO        $t .= $val;
     }
 
     return $t;