Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine

Re: Apache::ASP

by knobunc (Pilgrim)
on Feb 20, 2002 at 21:31 UTC ( #146640=note: print w/replies, xml ) Need Help??

in reply to Apache::ASP

Nice review.

For similar functionality with what I consider a cleaner interface and neater structure see HTML::Mason module review at (I realize the author mentions it, but I wanted to make the plug more prominent and provide links).

It can intersperse code and HTML (or whatever language, it is not tied to HTML, it could spit out text, XML, ASP, gifs, jpegs, you name it...). And it has an interesting component structre where each file is considered to be a component (whether or not it can be called externally) and components can call each other so you can make widgets that take arguments in mason as well as the top-level components that get called directly. Also it has a neat object-like hierarchy where you can define a method call to generate the page framework (a top, bottom and side for instance) and then all the other pages need to do is output the appropriate content for the content area. The sub-pages can override the methods of the lower-level pages to customize the way things display.


Replies are listed 'Best First'.
Re^2: Apache::ASP
by ivan (Sexton) on Sep 04, 2006 at 02:00 UTC
    I also found myself migrating from Apache::ASP to Mason. I must say, I'm much happier with Mason, personally. Here's a quick hack that can migrate the template format of a set of files from Apache::ASP to Mason. You still have to change any use of the Apache::ASP objects over, of course.
    #!/usr/bin/perl #foreach $file ( split(/\n/, `find . -depth -print`) ) { # next unless $file =~ /(cgi|html)$/; foreach $file ( @ARGV ) { open(F,$file) or die "can't open $file for reading: $!"; @file = <F>; #print "$file ". scalar(@file). "\n"; close $file; $newline = ''; #avoid prepending extraneous newlines $all = join('',@file); $w = ''; $mode = 'html'; while ( length($all) ) { if ( $mode eq 'html' ) { if ( $all =~ /^(.+?)(<%=?.*)$/s && $1 !~ /<%/s ) { $w .= $1; $all = $2; next; } elsif ( $all =~ /^<%=(.*)$/s ) { $w .= '<%'; $all = $1; $mode = 'perlv'; #die; next; } elsif ( $all =~ /^<%(.*)$/s ) { $w .= $newline; $newline = "\n"; $all = $1; $mode = 'perlc'; #avoid newline prepend fix from borking indented first <% $w =~ s/\n\s+\z/\n/; $w .= "\n" if $w =~ /.+\z/; next; } elsif ( $all !~ /<%/s ) { $w .= $all; last; } else { warn length($all); die; } die; } elsif ( $mode eq 'perlv' ) { if ( $all =~ /^(.*?%>)(.*)$/s ) { $w .= $1; $all=$2; $mode = 'html'; next; } die "unterminated <%= ??? (in $file):"; } elsif ( $mode eq 'perlc' ) { if ( $all =~ /^([^\n]*?)%>(.*)$/s ) { $w .= "%$1\n"; $all=$2; $mode='html'; next; } if ( $all =~ /^([^\n]*)\n(.*)$/s ) { $w .= "%$1\n"; $all=$2; next; } } else { die }; } system("chmod u+w $file"); select W; $| = 1; select STDOUT; open(W,">$file") or die "can't open $file for writing: $!"; print W $w; close W; }

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://146640]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (5)
As of 2017-06-25 16:44 GMT
Find Nodes?
    Voting Booth?
    How many monitors do you use while coding?

    Results (568 votes). Check out past polls.