#!/usr/bin/perl -w #----------------------------------------------------------------------- if ($#ARGV < 3) { print("Usage: $0 -o \n"); exit; } if ($ARGV[2] ne "-o") { print("Usage: $0 -o \n"); exit; } $hbFile = $ARGV[0]; $strFile = $ARGV[1]; $outFile = $ARGV[3]; open(STR_FILE, "<$strFile") or die "Could not open $strFile for reading: $!"; open(OUT, ">$outFile") or die "Could not open $outFile for writing: $!"; # get contents of HB file: { open(HB_FILE, "<$hbFile") or die "Could not open $hbFile for reading: $!"; local $/ = undef; $hb = ; close(HB_FILE); #print $hb; } # for each string pair, check input from hb file while() { # remove \n chop($_); $_ =~ s/\r//; # make sure it's not a blank line if (!/\"/) { next; } #print("Got line: $_\n"); # parse name and id $id = $_; $id =~ s/^.*,//; $id =~ s/^\s+|\s+$//g; $name = $_; $name =~ s/,.*$//g; #print("Spell $name id = $id.\n"); if ($id =~ /^\s*$/) { print("$name has no ID. skipping...\n"); next; } $hb =~ s/$name/$id/g; } # write the output file #print $hb; print OUT $hb; close OUT; close STR_FILE;