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 ,
I want to get like this >perl ClassChecker.pl AAA.java >ClassA >ClassB
Quick and dirty: $ perl -n -e 'print "$1\n" if /class\s+(\w+)/' AAA.java ClassA ClassB This does not know anything about Java syntax and just looks for a word after 'class' and some space. If it is in comments or you have something like public class Foo { } it won't understand it. More robust solutions are feasible. For example, after improving the recent CPAN module Parse::Java, you can do a lot better. To quote Randal, "Learn or hire". -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>