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?
 
ozoConnect With a Mentor Commented:
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
 
kopibeanAuthor Commented:
Can you explain all those lines of codes that you have produced??
THanks a lot
0
All Courses

From novice to tech pro — start learning today.