I'm sure there's a better way to do this, but it really isn't too hard.

-------------------------------------start---------------------------------------
#!/usr/bin/perl
use warnings;
use strict;

my $file = shift || die "Please provide a java file to check.\n";
my @lines = `cat $file`;

foreach (@lines) {
       /class (\w+)/ && print "$1\n";
}
--------------------------------------- end -------------------------

On 10/26/06, bou, hou (GE Money, consultant) <[EMAIL PROTECTED]> wrote:
hello, all
I want to get the Class name of .java file with perl ,
How can I do it ? I think it is difficult to result the java comment .
For Example
a java file named AAA.java
--------------------
/* author : John Smith */
// comment
public class ClassA {
  /*   */
  //comment
  public static void main(String[] args) {
  }
...
}
class ClassB {
...
}
---------------------
I want to get like this
>perl ClassChecker.pl AAA.java
>ClassA
>ClassB

thank u.

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>





--
I'm nerdy in the extreme and whiter than sour cream

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to