#!/usr/bin/perl

# convert octave script to Matlab script

while(<>){
    s/(\S+)\s*\+\+/$1 = $1 \+ 1/;
    s/(\S+)\s*--/$1 = $1 - 1/;
    s/#+/%/g;
    s/endfunction//g;
    s/endif/end/g;
    s/endfor/end/g;
    s/endwhile/end/g;
    s/endswitch/end/g;
    s/(\s+)printf\s*\(/$1fprintf\(1,/g;
    s/\|\|/\|/g;
    s/&&/&/g;
    s/"/'/g;
    s/!/~/g;
    s/global\s+(\S+)\s*=\s*(\S+)/global $1; $1 = $2/;
    print $_;
}

