This cannot run in perl 4 but perl 5

I run this code in perl version 4 and i get compilation errors. But there are no errors at all when i run in perl 5.
How do I change the below codes to suit the environment that is running in perl version 4?? I provided the codes and errors as listed below.
Please help!
Thanks a lot.


My codes:

open(FILEHANDLE1,"tablefile5") || die "Cannot open file\n";
@filecontents = <FILEHANDLE1>;


open(FILE,"<tablefile5") || die "Can't open tablefile5 because $!";
open(NEWFILE,">plusfile") || die "Can't open plusfile because $!";
$file = join'',<FILE>;




while( $file =~ /SYS_WAFERID!(\d+)(.*)SYS_WAFERID!\1/gs )
{
    $id=$1;  $wafer=$2;
    for( $wafer =~ /(.*!.*!.*!.*!)/g )
    {
        ($para) = /(\w+)/;
        push @para,$para unless $col{$para};
        push @{$col{$para}[$id]}, /!\+([0-9E.+\-]+)/g;
    }
}
close(FILE);

while( @para )
{
    @p3 = splice(@para,0,6);
    print NEWFILE "Waf si",(map{" ".substr($_,0,11)} @p3),"\n";
    print NEWFILE "      ",(map{" ".substr($_,12,11)} @p3),"\n";
    print NEWFILE "." x 78,"\n";
    for $id ( 0..$#{$col{$p3[0]}} )
    {
         for $r ( 0..$#{$col{$p3[0]}[$id]} )
         {
                printf NEWFILE "%3d   ",$id;
                print NEWFILE map{sprintf"%12.3E",$col{$_}->[$id]->[$r]} @p3;
                print NEWFILE "\n";
         }
         print NEWFILE "\n";
    }
}

Errors:

Substitution pattern not terminated in file ./final at line 26,next char ^?
syntax error in file ./final at line 26,next 2 tokens "/SYS_WAFERID!(\d+)(.*)SYS_WAFERID!\1/gs )"

syntax error in file ./final at line 34,next 2 tokens "@$col"
syntax error in file ./final at line 42,next 2 tokens "map{"
syntax error in file ./final at line 42,next 2 tokens "@p3)"
syntax error in file ./final at line 43,next 2 tokens "map{"
syntax error in file ./final at line 47,next 2 tokens "{["
syntax error in file ./final at line 50,next 2 tokens "map{"
syntax error in file ./final at line 52,next 2 tokens "}"
syntax error in file ./final at line 67,next token "}"
kopibeanAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ozoCommented:
open(FILE,"<tablefile5") || die "Can't open tablefile5 because $!";
open(NEWFILE,">plusfile") || die "Can't open plusfile because $!";
$file = join('',<FILE>);
while( $file =~ /SYS_WAFERID!(\d+)([^\0]*)SYS_WAFERID!\1/g ){
    $id=$1;  $wafer=$2;
    push(@id,$id) unless $id{$id}++;
    for( $wafer =~ /(.*!.*!.*!.*!)/g ){
        ($para) = /(\w+)/;
        push(@para,$para) unless $para{$para}++;
        @stuff = /!\+([0-9E.+\-]+)/g;
        for( 0..$#stuff ){ $col{$para,$id,$_} = $stuff[$_] }
        $maxlen = $#stuff if( $len < $#stuff );
  }
}
close(FILE);
while( @para ){
    @p3 = splice(@para,0,3);
    print NEWFILE "Waf si";
    for( @p3 ){ print NEWFILE " ",substr($_,0,11) }
    print NEWFILE "\n      ";
    for( @p3 ){ print NEWFILE " ",substr($_,11,11) }
    print NEWFILE "\n","." x 44,"\n";
    for $id ( @id ){
        for $r( 0..$maxlen ){
            printf NEWFILE "%3d    ",$id;
            for $para ( @p3 ){
                 printf NEWFILE ("%12.3E",$col{$para,$id,$r});
            }
            print NEWFILE "\n";
        }
        print NEWFILE "\n";
    }
}
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
kopibeanAuthor Commented:
Can you explain all those lines of codes that you have produced??
THanks a lot
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Perl

From novice to tech pro — start learning today.