Created
March 15, 2011 14:56
-
-
Save aembleton/870812 to your computer and use it in GitHub Desktop.
Call Perl number normalisation from Java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.BufferedReader; | |
import java.io.IOException; | |
import java.io.InputStreamReader; | |
public class Run { | |
public static void main(String args[]) { | |
Process process; | |
try { | |
process = Runtime.getRuntime().exec("perl normalize.pl 07882085327 GB"); | |
process.waitFor(); | |
if (process.exitValue() == 0) { | |
System.out.println("Command Successful"); | |
try { | |
BufferedReader in = new BufferedReader( | |
new InputStreamReader(process.getInputStream())); | |
String line = null; | |
while ((line = in.readLine()) != null) { | |
System.out.println(line); | |
} | |
} catch (IOException e) { | |
e.printStackTrace(); | |
} | |
} else { | |
System.out.println("Command Failure"); | |
} | |
} catch (Exception e) { | |
System.out.println("Exception: " + e.toString()); | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
use strict; | |
use warnings; | |
my $n = $ARGV[0]; | |
my $country = $ARGV[1]; | |
if ($country eq "GB") { | |
if ($n =~ /^0(\d{10})$/x) { | |
$n = "44" . "$1"; | |
} | |
} | |
print "+" . $n . "\n"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment