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: 
Using [Pattern](http://docs.oracle.com/javase/1.4.2/docs/api/java/util/regex/Pattern.html) class and regular expressions.
This method is equals to your method. 

```
public boolean haveDigit(String str) 
{
   Pattern p = Pattern.compile(".*[0-9].*");
   Matcher m = p.matcher(str);
   return m.matches();
}  

```

test

```
haveDigit("d9h");    //true
haveDigit("d9agh6"); //true
haveDigit("hello");  //false

```

Next method checks what you ask

```
public boolean isNumeric(String str) 
{
   Pattern p = Pattern.compile("[0-9]+");
   Matcher m = p.matcher(str);
   return m.matches();
}  

```

test 

```
isNumeric("r5t"); // false
isNumeric("100"); // true
isNumeric("0.5"); // false

```
What about `Integer.parseInt(String)` to see if an integer exists. 

```
public boolean checkNumeric(String str) {
    try { 
         Integer.parseInt(str);  // parse to check if the integer is an integer
         return true;
     } catch (NumberFormatException ne) {
         return false;
 }

```