Hi all,
As part of migrating a large embperl site from HTML::Embperl
I ended up
whipping up a quick script to convert plus blocks and
foreach loops to
the format required by Embperl 2.x.
There are still other issues as I work through things but
these relate
to either the current working directory not being the
basename of the
file being executed or html construct nesting issues which
should be
cleaned up anyway.
(I'm not claiming this is perfect but it does 99% which is
good enough
for me )
Hopefully someone might find this useful.
This does the following:
1) removes trailing semicolons from plus blocks
[+ $something; +] -> [+ $something +]
[+ do { blah; foo; bar; }; +] -> [+ do { blah; foo; bar;
} +]
2) wraps multistatement plus blocks in do{} constructs
[+ $a=1; $a +] -> [+ do { $a=1; $a } +]
3) makes sure all [$ foreach $] argument lists are contained
in round
brackets
[$ foreach $a list $] -> [$ foreach $a ( list) $]
[$ foreach $a 'foo', 'bar' $] -> [$ foreach $a ('foo',
'bar') $]
Usage: convert_embperl_files.pl --dir directory [--dir
directory2]
--match filematch [--match filematch2]
[--potent] [--verbose] [--exclude path]
-d, --dir A base directory to recurse from. May be
given
more than once.
-m, --match A file glob or regex to match filename. May
be
given more than once
-b, --backup Back up each matched file with a .bak
extension
-e, --exclude A full directory name to exclude. It is
anchored
at the beginning of the file path when
tested.
-l, --limit Change at most this many files
-p, --potent Actually perform file content
substitutions.
-v, --verbose Increase verbosity. May be given more than
once
Eg: convert_embperl_files.pl -d /var/www/mysite -m '*.epl'
-m '*.html' -e /var/www/mysite/not_embperl -v -v
--
Andrew O'Brien
------------------------------------------------------------
---------
To unsubscribe, e-mail: embperl-unsubscribe perl.apache.org
For additional commands, e-mail: embperl-help perl.apache.org
|