home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / ftes46b5.zip / ftes46b5 / src / mkdefcfg.pl < prev    next >
Perl Script  |  1997-05-30  |  726b  |  35 lines

  1. #!perl -w
  2. print "/* do not edit */\nchar DefaultConfig[] = {\n";
  3.  
  4. $n = 1;
  5. $buf = "";
  6. $out = "";
  7. while (($len = sysread(STDIN, $buf, 256)) > 0) {
  8.     #$buf =~ s/(.)/sprintf "0x%02X", ord($1))/goe;
  9.     #for ($i = 0; $i < $len; $i++) {
  10.     #    $out .= sprintf "0x%02X", ord(substr($buf, $i, 1,));
  11.     #    if ($n++ % 10) {
  12.     #        $out .= ", ";
  13.     #    } else {
  14.     #        $out .= ",\n";
  15.     #    }
  16.     #}
  17.  
  18.     @c = split(//, $buf);
  19.     for ($i = 0; $i < $len; $i++) {
  20.         $out .= sprintf("0x%02X", ord($c[$i]));
  21.         if ($n++ % 10) {
  22.             $out .= ", ";
  23.         } else {
  24.             $out .= ",\n";
  25.         }
  26.     }
  27.  
  28.     print $out;
  29.     $out = "";
  30.     print STDERR ".";
  31. }
  32. print "\n};\n";
  33. print STDERR "\n";
  34.  
  35.