Click here to Skip to main content
15,891,905 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi and Happy new year.
Is there anywhere perl script converter to other languages like c++ or c#?
If yes, can you please give me link to it, or can you write this code:
PERL
foreach $pair (split('&', $form)) 
   {
   if ($pair =~ /(.*)=(.*)/) 
     {  
      ($key,$value) = ($1,$2);    
      $value =~ s/\+/ /g; 
     $value =~ s/%(..)/pack('c',hex($1))/eg;
	  $value =~ s/%0D%0A/ /eg;
      $inputs{$key} = $value;   
     }
  }	 

in c++ or c#?
Posted
Updated 27-Nov-17 20:10pm
Comments
[no name] 2-Jan-15 12:53pm    
I think this small piece of code is a good exercise to translate it by yourself :-)
[no name] 2-Jan-15 13:04pm    
I can feel with you after a closer look to the pearl perl code.
Afzaal Ahmad Zeeshan 2-Jan-15 13:32pm    
It is perl, just in case to fix your typo ;-)
[no name] 2-Jan-15 13:40pm    
Thanks :)
Bruno
Sergey Alexandrovich Kryukov 2-Jan-15 13:32pm    
This is a counter-productive approach. Suppose someone "convert" it (white analogous code, in fact) in C++ or C#, now what? You still don't know those languages and technologies (it you knew them, you would do this work by yourself). So, what would you do with that new code? Please understand: no one likes to waste one's time on something useless.
—SA

It doesn't quite work like that.
We do not do your work for you, either homework or your paid job.
If you want someone to write your code, you have to pay - I suggest you go to Freelancer.com and ask there.

But be aware: you get what you pay for. Pay peanuts, get monkeys.

I assume that you didn't write the perl code, and have no idea how it works (and possibly have no idea how perl works either) - so I'd start by looking at what the code is meant to do and working out how to implement that in C# or C++. Translating blindly between languages (with the exception of VB and C# which are pretty much interchangeable) is not normally a good approach: what works well in one language is very rarely an optimal solution in another. Just look at what works in native C++ and how it should be done in C# and you will get the idea - and they share a huge amount of syntax in common!
 
Share this answer
 
Your C or C# program can invoke the perl shell as an external command.

Here is a C# example.

https://social.msdn.microsoft.com/Forums/vstudio/en-US/ea9455e1-b254-49e1-99df-41718ea80b5b/how-to-run-perl-scripts-in-c?forum=csharpgeneral[^]

Your C program can link to the Perl interpreter directly.

http://perldoc.perl.org/perlembed.html[^]
 
Share this answer
 
This only makes sense as an isolated exercise to venture into new territory.
If the source language (perl in this case) is too dense, translate it first into some invented pseudo code. Name each operation with a function name (e.g. substitute all ocurances of pattern X in variable Y by text Z, and assign it back to variable Y, etc.).
With this, the original code is understood. You may now try to find matching functionality in the target language. Translate it from there...
Cheers
Andi
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900