From gerber at id.ethz.ch Thu Aug 21 06:48:07 2008 From: gerber at id.ethz.ch (Thedi Gerber) Date: Thu Aug 21 06:48:17 2008 Subject: [Petal] Bug report: Dollar follwed by a name gets lost Message-ID: <48AD0197.2070804@id.ethz.ch> We are currently starting a new project and would like to use Petal. While doing some exercises to get to know it, i tried to include a small example perl script in a template. To my surprise, variable names in the perl source were lost. After some more tests, I came to this conclusion: $variable IN THE template magically disappears $1000 is ok $n is ok (single letter following a $) ... replaces the content always ok Here is a small example: ---------------------------------- my template:

10 dollars are $10, n dollars are $n, but nn dollars disapear $nn!

---------------------------------- my perl script #!/usr/bin/perl -w use strict; use utf8; binmode STDOUT, ':utf8'; use Petal; my $task = new Petal( file => 't.tmpl', output => 'HTML', # required to process ü seqences OK ); my %content_data = ( ); my $task_result = $task->process( \%content_data ); print $task_result; print "\n", '=' x 50, "\n"; print "Petal::VERSION=", $Petal::VERSION, "\n"; print "\n", '=' x 50, "\n"; print `perl -V`; print "\n", '=' x 50, "\n"; ----------------------------------- I get this output (missing $nn)

10 dollars are $10, n dollars are $n, but nn dollars disapear !

================================================== Petal::VERSION=2.19 ================================================== Summary of my perl5 (revision 5 version 8 subversion 8) configuration: Platform: osname=darwin, osvers=9.0, archname=darwin-thread-multi-2level uname='darwin omen.apple.com 9.0 darwin kernel version 9.0.0b5: mon sep 10 17:17:11 pdt 2007; root:xnu-1166.6~1release_ppc power macintosh ' config_args='-ds -e -Dprefix=/usr -Dccflags=-g -pipe -Dldflags=-Dman3ext=3pm -Duseithreads -Duseshrplib' hint=recommended, useposix=true, d_sigaction=define usethreads=define use5005threads=undef useithreads=define usemultiplicity=define useperlio=define d_sfio=undef uselargefiles=define usesocks=undef use64bitint=define use64bitall=define uselongdouble=undef usemymalloc=n, bincompat5005=undef Compiler: cc='cc', ccflags ='-arch i386 -arch ppc -g -pipe -fno-common -DPERL_DARWIN -no-cpp-precomp -fno-strict-aliasing -Wdeclaration-after-statement -I/usr/local/include', optimize='-O3', cppflags='-no-cpp-precomp -g -pipe -fno-common -DPERL_DARWIN -no-cpp-precomp -fno-strict-aliasing -Wdeclaration-after-statement -I/usr/local/include' ccversion='', gccversion='4.0.1 (Apple Inc. build 5465)', gccosandvers='' intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234 d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16 ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8 alignbytes=8, prototype=define Linker and Libraries: ld='cc -mmacosx-version-min=10.5', ldflags ='-arch i386 -arch ppc -L/usr/local/lib' libpth=/usr/local/lib /usr/lib libs=-ldbm -ldl -lm -lutil -lc perllibs=-ldl -lm -lutil -lc libc=/usr/lib/libc.dylib, so=dylib, useshrplib=true, libperl=libperl.dylib gnulibc_version='' Dynamic Linking: dlsrc=dl_dlopen.xs, dlext=bundle, d_dlsymun=undef, ccdlflags=' ' cccdlflags=' ', lddlflags='-arch i386 -arch ppc -bundle -undefined dynamic_lookup -L/usr/local/lib' Characteristics of this binary (from libperl): Compile-time options: MULTIPLICITY PERL_IMPLICIT_CONTEXT PERL_MALLOC_WRAP USE_ITHREADS USE_LARGE_FILES USE_PERLIO USE_REENTRANT_API Locally applied patches: fix for regcomp CVE-2007-5116 security vulnerability Built under darwin Compiled at Dec 7 2007 09:37:29 %ENV: PERL5LIB="/sw/lib/perl5:/sw/lib/perl5/darwin" @INC: /sw/lib/perl5 /sw/lib/perl5/darwin /System/Library/Perl/5.8.8/darwin-thread-multi-2level /System/Library/Perl/5.8.8 /Library/Perl/5.8.8/darwin-thread-multi-2level /Library/Perl/5.8.8 /Library/Perl /Network/Library/Perl/5.8.8/darwin-thread-multi-2level /Network/Library/Perl/5.8.8 /Network/Library/Perl /System/Library/Perl/Extras/5.8.8/darwin-thread-multi-2level /System/Library/Perl/Extras/5.8.8 /Library/Perl/5.8.6 /Library/Perl/5.8.1 . From mark at thinkfoo.com Thu Aug 21 10:09:51 2008 From: mark at thinkfoo.com (Mark Holland) Date: Thu Aug 21 10:10:13 2008 Subject: [Petal] Bug report: Dollar follwed by a name gets lost In-Reply-To: <48AD0197.2070804@id.ethz.ch> References: <48AD0197.2070804@id.ethz.ch> Message-ID: <48AD30DF.2060700@thinkfoo.com> On 21/08/08 06:48, Thedi Gerber wrote: > We are currently starting a new project and would like to use Petal. > While doing some exercises to get to know it, i tried to include a small > example perl script in a template. To my surprise, variable names in the > perl source were lost. > > After some more tests, I came to this conclusion: > > $variable IN THE template magically disappears > $1000 is ok > $n is ok (single letter following a $) > ... replaces the content always ok Petal is interpolating $variable with parameters passed through ->process(). If you were to pass through 'variable' as a argument you would see it printed. ($1000 and $n are not regarded as valid variable names). E.g. if you were to change the following in your example: my %content_data = (nn => 'foo'); my $task_result = $task->process( \%content_data ); you will see the output: "but nn dollars disappear foo!" I've forgotten if there's a proper way to escape dollar characters in Petal, but one work around would be to use html entites, e.g.: This costs $45 Cheers ~mark