Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??
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; }

In reply to Re^2: Apache::ASP by ivan
in thread Apache::ASP by trs80

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others contemplating the Monastery: (6)
    As of 2014-09-17 09:33 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      How do you remember the number of days in each month?











      Results (70 votes), past polls