While Blair's response is admirable (I was impressed), this forum is not really meant to outsource your own work. I would recommend you begin translating this code to C# yourself (which you might be paid to do), and you'll learn more along the way. If you have specific questions about the C# language, then ask away!
It looked like you were soliciting people to rewrite your perl code to C#. If your question was originally to find out if there was a tool that does it, I don't know personally, but others might. Have you searched the web (I have but nothing came up.)
I think that trying to directly convert a perl script to a C# program is useless. You can of course try to convert some algorithms, but conversion of whole programs is too much for any computer (~programmer). The solutions in perl script may be done totally differently in C#.
The Best Solution to this conversion is to just LEARN AND MASTER both Perl and C#, and then implement C# program that meets the original requirements set to the perl script. Do not try to copy the perl code to C# code, it won't work, at least at the higher levels.
First understand the responsibilities of the perl script, and then study how the similar functionality is done in .NET. I can assure, that there are major differences.
I need to convert this perl code into C Sharp code:
#!/usr/bin/perl -w
#Please, tell me any tool which can do so.
#!/usr/bin/perl -w simple tells the *NIX shell environment that this executable file is a perl script, and needs to be interpreted by /usr/bin/perl with -w (shows warnings).
There's no need to convert it, as C# apps are .EXE files, and Windows already knows how to execute them.
Convert Perl Code to C#
Snuggs
Hi,
Can u help me
I need to convert this perl code into C Sharp code:
#!/usr/bin/perl -w
#Please, tell me any tool which can do so.
bfoster
It's not too big.
I am pasting it here.
It reads a pipe delimeted file fetches some data and write it to another file.
Following is the complete script
eval '$'.$1.'$2;' while $ARGV[0] =~ /^([A-Za-z_0-9]+=)(.*)/ && shift;
$[ = 1; # set array base to 1
$, = ' '; # set output field separator
$\ = "\n"; # set output record separator
$FS = '|';
while (<>) {
chomp; # strip record separator
($Fld1,$Fld2,$Fld3,$Fld4,$Fld5,$Fld6,$Fld7,$Fld8,$Fld9,$Fld10,$Fld11,$Fld12,$Fld13,$Fld14,$Fld15,$Fld16,$Fld17,$Fld18,$Fld19,$Fld20,$Fld21,$Fld22,$Fld23,$Fld24,$Fld25,$Fld26,$Fld27,$Fld28,$Fld29,$Fld30,$Fld31,$Fld32,$Fld33,$Fld34,$Fld35) = split('\|', $_, 9999);
$S = $Fld2 . $FS . $Fld3 . $FS . $Fld4;
$k = $Fld35 . $FS . $Fld15 . $FS . $Fld16 . $FS . $Fld33 . $FS . $Fld34 . $FS . $Fld25;
if (defined $neigh{$S}) {
$neigh{$S} = $neigh{$S} . ',' . $k;
}
else {
$neigh{$S} = $k;
}
}
foreach $S (keys %neigh) {
$n = (@a = split(/,/, $neigh{$S}, 9999));
for ($i = 1; $i <= $n; $i++) {
print $S . $FS . $i . $FS . $a[$i] . $FS;
}
}
neutronron
Eddie Tse
me looking for same,
// chall3ng3r //
Etienne Tremblay
While Blair's response is admirable (I was impressed), this forum is not really meant to outsource your own work. I would recommend you begin translating this code to C# yourself (which you might be paid to do), and you'll learn more along the way. If you have specific questions about the C# language, then ask away!
Brian Kramer / C++ MVP
kaushalparik
{
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 ]);
}
}
russlunn
It looked like you were soliciting people to rewrite your perl code to C#. If your question was originally to find out if there was a tool that does it, I don't know personally, but others might. Have you searched the web (I have but nothing came up.)
Brian
abhijit_ghawate
The Best Solution to this conversion is to just LEARN AND MASTER both Perl and C#, and then implement C# program that meets the original requirements set to the perl script. Do not try to copy the perl code to C# code, it won't work, at least at the higher levels.
First understand the responsibilities of the perl script, and then study how the similar functionality is done in .NET. I can assure, that there are major differences.
BuffaloUS
Jim Vobrak
How big is it
email to me and let me take a stab
Jason Hayes
#!/usr/bin/perl -w simple tells the *NIX shell environment that this executable file is a perl script, and needs to be interpreted by /usr/bin/perl with -w (shows warnings).
There's no need to convert it, as C# apps are .EXE files, and Windows already knows how to execute them.