PDA

View Full Version : perl---> java..



wzwz123456
October 15th, 2008, 05:15 PM
can any one convert the below perl code to java...

open(AGE, $readf) || die "$readf.\n";

while (my $line = <AGE>)
{
chomp($line);
my @array = split(/\s+/, $line);
my $index = $array[Pindex];
my $value = $array[Kindex];
}

geirha
October 15th, 2008, 05:25 PM
I can give you some tips. Use the Scanner (http://java.sun.com/j2se/1.5.0/docs/api/java/util/Scanner.html) class to read lines using the nextLine() method.

String (http://java.sun.com/j2se/1.5.0/docs/api/java/lang/String.html)s have some split methods that can split on regexes.