From: Xxxxx Xxxxxx To: mjd@plover.com Subject: Text::Template Date: Mon, 20 Nov 2006 01:59:30 +0100 - templates with size zero generate an error. It's easy for me to check but I believe it should be allowed. There is nothing wrong with an empty template. Cheers, Xxxxx. To: Xxxxx Xxxxxx ================================================================ Subject: Re: Text::Template Date: Sun, 19 Nov 2006 20:48:41 -0500 From: Mark Jason Dominus > - templates with size zero generate an error. > It's easy for me to check but I > believe it should be allowed. There is nothing wrong with an empty template. I agree, but was unable to reproduce the problem. Please send me a test program that demonstrates the error. ================================================================ From: Xxxxx Xxxxxx To: Mark Jason Dominus Subject: Re: Text::Template Date: Mon, 20 Nov 2006 22:25:16 +0100 I attach an example. create a directory named test_template and "touch" a file named 'tes' in it. [xxxxx@xxxxx perl_modules]$ ls -ls test_template/ total 0 0 -rw-r--r-- 1 xxxxx users 0 Nov 20 22:14 test [xxxxx@xxxxx perl_modules]$ perl test_text_template.pl Error: Can't evaluate template!. Returning undef from 'fill_in' when the file has zero size is not really an error but returning an empty string would be nicer IMO. use Text::Template ; my $template = Text::Template->new ( TYPE => 'FILE' , SOURCE => 'test_template/test' , DELIMITERS => ['{{', '}}'] ); my $text = $template->fill_in(HASH => { A => 1}) or die "Error: Can't evaluate template!.\n" ; ================================================================ To: Xxxxx Xxxxxx Subject: Re: Text::Template Date: Mon, 20 Nov 2006 15:20:20 -0500 From: Mark Jason Dominus > Returning undef from 'fill_in' when the file has zero size is not really an > error but returning an empty string would be nicer IMO. It does not return undef; it does return the empty string. Your program does not demonstrate any failure; it demonstrates the function successfully returning the empty string, as it should. Try this: use Text::Template ; my $template = Text::Template->new ( TYPE => 'FILE' , SOURCE => 'test_template/test' , DELIMITERS => ['{{', '}}'] ) or die; my $result = $template->fill_in(HASH => { A => 1}); if (defined $result) { print "Success: result is <<$result>>\n"; } else { die "Error: Can't evaluate template ($Text::Template::ERROR)" ; } When I run this, I get Success: result is <<>> which I beleve is exactly what it should be doing.