Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: Calling a perl test script from visual studio?

by dbuckhal (Chaplain)
on Feb 28, 2014 at 20:42 UTC ( [id://1076616]=note: print w/replies, xml ) Need Help??


in reply to Calling a perl test script from visual studio?

What language are you using in Visual Studio?

For ProjectEuler Problem 11, I wrote a solution in C#, as well as Perl. Then I thought it would be interesting to use Perl to generate a n x n random number array for the C# program.

So, I browsed around and found an example to execute Perl from within C# code. It then stores the array in "data" for C# to process.

Maybe this might be something of use to you?

// confiure Perl number generator string perlCommand = @"C:\cygwin\bin\perl.exe"; // your Perl string perlScript = "ranArrayGen.pl"; // your script // how big of array ( default = 20 x 20 ) Console.Write("Enter desired array size [20]: "); string perlArg = Console.ReadLine(); int readInt; if ( !int.TryParse( perlArg, out readInt ) ) perlArg = "20"; // setup process info for script ProcessStartInfo perlStartInfo = new ProcessStartInfo(perlCommand); perlStartInfo.Arguments = perlScript + " " + perlArg; perlStartInfo.UseShellExecute = false; perlStartInfo.RedirectStandardOutput = true; // execute Perl number generator Process perl = new Process(); perl.StartInfo = perlStartInfo; perl.Start(); string data = perl.StandardOutput.ReadToEnd(); perl.WaitForExit(); perl.Close(); // display working array data Console.WriteLine("Using:\n{0}", data);

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1076616]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (2)
As of 2024-04-20 15:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found