summaryrefslogtreecommitdiff
path: root/mad/p55
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2006-03-09 22:03:55 +0000
committerNicholas Clark <nick@ccl4.org>2006-03-09 22:03:55 +0000
commit6a28abbc8c08ff5da570415ad3f8a343b51e103d (patch)
tree4a8c897e11e6ccb3b7d2824f1472042a20980cd3 /mad/p55
parent32d45c1d3bb497e6d65453056058531c637f7772 (diff)
downloadperl-6a28abbc8c08ff5da570415ad3f8a343b51e103d.tar.gz
Add the Perl 5 to Perl 5 convertor scripts.
p4raw-id: //depot/perl@27453
Diffstat (limited to 'mad/p55')
-rwxr-xr-xmad/p5569
1 files changed, 69 insertions, 0 deletions
diff --git a/mad/p55 b/mad/p55
new file mode 100755
index 0000000000..20b879bbd2
--- /dev/null
+++ b/mad/p55
@@ -0,0 +1,69 @@
+#!/usr/bin/perl
+
+while (@ARGV and $ARGV[0] =~ /^-/) {
+ my $switch = shift;
+ if ($switch eq '-Y') {
+ $YAML = '-Y ';
+ }
+ else {
+ die "Unrecognized switch: -$switch";
+ }
+}
+
+my $file = shift;
+my $infile = $file;
+
+unlink "$file.msg";
+my $top = "/home/larry/src/p55";
+
+my $text;
+open(FILE, $file) or die "Can't open $file: $!\n";
+{
+ local $/;
+ $text = <FILE>;
+}
+close FILE;
+my $T;
+$switches = $1 if $text =~ /^#!.*?\s(-.*)/;
+$switches =~ s/\s+-[-*].*//;
+$switches =~ s/\s+#.*//;
+
+#if ($text =~ s/\bexit\b/DUMMYEXIT/g) {
+# $infile = "$file.tmp";
+# open FILE, ">$infile";
+# print FILE $text;
+# close FILE;
+#}
+
+unlink "$file.xml", "$file.msg", "$file.err", "$file.diff", "$file.p5";
+print "PERL_XMLDUMP='$file.xml' $top/perl $switches -I lib $infile 2>$file.err\n";
+system "PERL_XMLDUMP='$file.xml' $top/perl $switches -I lib $infile 2>$file.err";
+
+if ($?) {
+ print "Exit status $?\n";
+ system "cat $file.err";
+ exit 1;
+}
+
+if (not -s "$file.xml") {
+ die "Didn't produce an xml file!?!\n"
+}
+
+if ($YAML) {
+ system "$top/nomad -Y $file.xml";
+ exit;
+}
+
+system "$top/nomad $file.xml >$file.p5 2>$file.msg";
+
+if ($?) {
+ print "Oops!\n" unless -s "$file.msg";
+ system "cat $file.msg";
+ exit 1;
+}
+
+system "diff -u $file $file.p5 >$file.diff";
+if (-s "$file.diff") {
+ system "cat $file.diff";
+ exit 1;
+}