#!/usr/bin/perl #!/usr/bin/perl ## Rodolfo Garcia kix_at_kix.es ## suspend database management v1.0 use Switch; switch ($#ARGV) { case 0 { my $fin = $ARGV[0]; open(INF, "<$fin") or die "Could not open input file\n"; open(OUF, ">&STDOUT") or die "Could not open output file\n"; } case 1 { my $fin = $ARGV[0]; my $fout = $ARGV[1]; open(INF, "<$fin") or die "Could not open input file\n"; open(OUF, ">$fout") or die "Could not open output file\n"; } else { my $msg = $0 . " [output-file]"; die $msg; } } # We have two important cases, comment and info while() { if (/\s*\/\*(.*)\*\/$/) { $comments = "/*" . $1 . "*/"; } if (/\s*{\s*"([^"]*)",\s*"([^"]*)",\s*"([^"]*)",\s*"([^"]*)",\s*([\w\|]*)\s*}\s*,\s*(.*)/) { $sys_vendor = $1; $sys_product = $2; $sys_version = $3; $bios_version = $4; $flags = $5; print OUF "\"" . $sys_vendor . "\", \"" . $sys_product . "\", \"" . $sys_version . "\", \"" . $bios_version . "\", " . $flags . ", " . $comments . "\n"; } } close(INF); close(OUF);