2 questions
hi, I've sent this email to Template-Toolkit mailing list... but there doesn't seem to be anyone, so I'm sending it here ... Could anyone help me out with these ok I have two questions about TT, let me begin with the first one the easier ... I have the folowing situations I have a template like this $vars = { stuff = 'filename.tpl' }; then in the parent template [% INCLUDE $stuff %] Ok the problem is that sometimes I generate the contens on the fly so I can have in $stuff not the file name, but the content itself i.e. $vars = { stuff = 'tabletrtdblah/td/tr/table' } i.e. I need [% $stuff %] not [% INCLUDE $stuff %] How can in the parent template distinguish between these two cases (if scalar place it, if file include it ). There is third case what if it is scalar-template - then we have to parse/process the scalar.. Now the SECOND question : This is mostly related to FORMS ( i've done one module that generate for me forms content, insert/update queries, filled forms from a common config file), so what I need ... I need a way to replace the web-designer inputs,select boxes, textareas with thouse generated from me, but also want to preserve the formating/styles etc.. f.e. Designer wrote (the idea is ): select name=blah size=10 style=... option .. option .. option .. /select input type=text size=10 class=blah I have to remove select input but preserve the size, style and class - replace name with name created by me - and extract input-type for further usage in my script... Also I'm populating the SELECT-options from the DB so I must replace the designers-made with mine. it has to be some sort of callback function that will be called every time the TT hit some form-element... I thought of several variants with using WRAPPER, BLOCK.. !?! which doesn't help me alot possibly this has to be some sort of FILTER ?! has to have the ability to get arguments !?!? May be : [%FILTER parse(tplname=myslect, size=10, style=...)%] select name=blah size=10 style=... option .. option .. option .. /select [%END%] [%FILTER parse(tplname=myin, size=12, class=blah)%] input type=text size=12 class=blah [%END%] Please help me... i haven't written a filter !?! is there any other solution !?!? Thanx alot = iVAN [EMAIL PROTECTED] =
ASP.pm and script %main (name-table) !?
hi, How can I access the current script name-table from module. I'm currently using : $main::XXX = 123; Then in the script : print $XXX; but this access the ASP %main not the script %main ... Is there a way to access script main package and pull data there I'm working with ASP.pm-mod_perl thanx alot = iVAN [EMAIL PROTECTED] =
ASP.pm and multipart/form .. error
hi there , I encoutred a problem with ASP.pm (ver.2.17) and multipart form what is happening is that when I try to use file fields I get something like this into the log [Mon Jul 9 23:20:22 2001] [error] [client 192.168.0.5] Invalid method in request -7d11b8668d0668 [Mon Jul 9 23:20:41 2001] [error] [client 192.168.0.5] Invalid method in request -7d13c1268d0668 [Mon Jul 9 23:21:41 2001] [error] [client 192.168.0.2] Invalid method in request -7d17811a20 if the form is normal (w/o enctype=multipart/form-data ) I'm getting normally data into $Request.. nothing is crashing just I'm getting nothing into $Request collection... Additional info : CGI (3.2), Apache 1.3.20, mod_perl I think 1.25 i.e. www.apachetoolbox.com - ver 1.5.32 Can anyone confirm this !?! or tell me how can solve it ?! I'm continuing with the tests. :) = iVAN [EMAIL PROTECTED] =
[job] need a perl guru?
mod_ and regular flavours. http://420.am/~ivan/resume.html -- meow _ivan
[job] need a perl guru?
mod_ and regular flavours. http://420.am/~ivan/resume.html -- meow _ivan
Re: perl's memory leak
No, i did not mean freeing memory from lexicals. I meant the memory allocated for the temporary results, such as my $a = 'x' x 100 Here perl allocates 1M for $a and 1M for evaluating the right part, after that it is possible to undef $a and reuse its memory (1M), but the right part memory (one more 1M) can be used nowhere except the same line of code. This is strange. I understand that it can be an optimization trick, but when you frequently operate with megabytes, this becomes a pleasant feature which looks and behaves like a memory leak :) Ivan The matter is that perl DOES NOT REUSE MEMORY allocated for intermediate calculation results. This is specially harmful to data-intensive modperl applications where one perl process processes many queries and can leak great amount of memory. This is known and it's not really a leak. Perl knows about that memory and does re-use it, the next time it needs that lexical variable. It's a performance optimization. Try running your code multiple times and you should see memory stay at the same level after the first run. There has been discussion about this on the mailing list which you can find in the archives. There has also been talk about changing this behavior for mod_perl 2, which Doug is working on. Anyway, if you just want the memory back, undef your lexicals after you finish with them. - Perrin - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
perl's memory leak
Today I discovered a strange behaiviour of perl, and I wonder if anybody can tell me what to do with it. The matter is that perl DOES NOT REUSE MEMORY allocated for intermediate calculation results. This is specially harmful to data-intensive modperl applications where one perl process processes many queries and can leak great amount of memory. The example is below: use BSD::Resource; my $cc = 'a' x 2000 ;# alocates 20Mb for the right part and # 20Mb for $a p; { my $a = $cc.'x'; # allocates 20 more Mb for right part # and 20 for a p; undef $a; # deallocates $a } p; { my $b = $cc.'y'; # allocates 20 more Mb for right part # and reuses deallocated 20Mb for b p; undef $b; } p; sub p { print STDERR "used memory = ".(BSD::Resource::getrusage)[2]."\n" } # end of example. Output: used memory = 40772 used memory = 79804 used memory = 80068 used memory = 99676 used memory = 99700 ## Here I used BSD:Resource to measure consumed memory. Its result seems to be correlated with the amount of memory taken by the process from the OS. # This was checked on FreeBSD 3.4 and 4.2 ; and perl5.00405 5.00503 . Same things where noticed on Linux and probably on Solaris too. Ivan - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: perl's memory leak
You probably tried this script on linux or some other not fully BSD compartible system. We obtained same zeros on linux, where getrusage() means something else than on FreeBSD, but if you try measuring memory sizes with ps or top, you should observe the mentioned leak. Please insert sleep(10) after print STDERR and watch "top". Ivan On Thu, 7 Dec 2000 [EMAIL PROTECTED] wrote: The output I get is used memory = 0 used memory = 0 used memory = 0 used memory = 0 used memory = 0 I'm interested in how many leaks are possible in mod_perl though because my mod_perl processes are getting bigger with time -- about 200 requests is making the process fatter by 1mb on the average. I'm watching to see if they will max out around the current level of 10 mb per child. On Thu, Dec 07, 2000 at 07:53:16PM +0300, Ivan E. Panchenko wrote: Today I discovered a strange behaiviour of perl, and I wonder if anybody can tell me what to do with it. The matter is that perl DOES NOT REUSE MEMORY allocated for intermediate calculation results. This is specially harmful to data-intensive modperl applications where one perl process processes many queries and can leak great amount of memory. The example is below: use BSD::Resource; my $cc = 'a' x 2000 ;# alocates 20Mb for the right part and # 20Mb for $a p; { my $a = $cc.'x'; # allocates 20 more Mb for right part # and 20 for a p; undef $a; # deallocates $a } p; { my $b = $cc.'y'; # allocates 20 more Mb for right part # and reuses deallocated 20Mb for b p; undef $b; } p; sub p { print STDERR "used memory = ".(BSD::Resource::getrusage)[2]."\n" } # end of example. Output: used memory = 40772 used memory = 79804 used memory = 80068 used memory = 99676 used memory = 99700 ## Here I used BSD:Resource to measure consumed memory. Its result seems to be correlated with the amount of memory taken by the process from the OS. # This was checked on FreeBSD 3.4 and 4.2 ; and perl5.00405 5.00503 . Same things where noticed on Linux and probably on Solaris too. Ivan - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]