Convert Perl Script to C#
Make Use of the following function to convert your Perl Script to C#:
public void PerlTransFile(string filename)
{
string outDelim = ",";
char fs = '|';
Hashtable neigh = new Hashtable();
using (StreamReader sr = new StreamReader("TestFile.txt"))
{
string line;
while ((line = sr.ReadLine()) != null)
{
string[] temp = line.Split(fs);
neigh[string.Format("{1}{0}{2}{0}{3}", fs.ToString(), temp[1], temp[2], temp[3])] =
string.Format("{1}{0}{2}{0}{3}{0}{4}{0}{5}{6}",
fs.ToString(), temp[34], temp[14], temp[15], temp[32], temp[33], temp[24]);
}
foreach(string key in neigh.Keys)
{
string[] a = neigh[key].ToString().Split(',');
for(i = 0 ; i < a.Length; i++)
Console.WriteLine("{1}{0}{2}{0}{3}{0}", fs, key, i, a[ i ]);
}
}
If i use this i get an IndexOutOfRangeException everytime i use it on the first line of my Perl Script.
ReplyDeleteCan you post the Code? Are you keeping the Perl script in a flat file??
ReplyDelete