Question: I'm new to both C# and Perl, but I've been programming in other languages for a few years now. But anyways, I've been trying to write a simple program that passes a value from a C# program to a Perl script via its STDIN. The C# program opens the Perl script just fine, but I cant seem to figure out a way to pass a '1' to it. what would the best way of doing this be? I've searched far and wide for solutions, with no luck...

The C# code: 

```
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace OpenPerl
{
    class Program
    {
        static void Main(string[] args)
        {
            string path ="Z:\\folder\\test.pl";
            Process p = new Process();
            Process.Start(path, @"1");
        }
    }
}

```

The Perl program

```
#!/usr/bin/perl
use strict;
use warnings;
print "Enter 1: ";
my $number=<STDIN>;
if($number==1)
{
    print "You entered 1\n\n";
}

```

Answer: 
You can make use of regex here. Currently your code is testing if the string contains at least one digit. If you want that, you can use:

```
// Modification of your code. Test string contains at least 1 digit
public boolean haveDigit(String str) {
    return !str.replaceAll("\\D+", "").isEmpty();
}

```

But as per your text, you want to test if the string only contains a digit. For that you can use:

```
// Test is string only contains digit and no other character
public boolean isDigit(String str) {
    return str.matches("\\d+");
}

```
```
public boolean isNumeric(String num)
{
    try
    {
        Integer.parseInt(num);
        return true;
    }
    catch(NumberFormatException e)
    {
        return false;
    }
}

```