From: "Andy Greenwood" <[EMAIL PROTECTED]> > 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`;
AUUUUUUUU!!! open my $IN, '<', $file or die "Can't open $file: $^E\n"; @lines = <$IN>; close $IN; is much much more efficient and unlike the cat it's actually portable! > foreach (@lines) { > /class (\w+)/ && print "$1\n"; > } You do not actually need to load the whole file into an array and then loop through the array, this would be better: open my $IN, '<', $file or die "Can't open $file: $^E\n"; while (<$IN>) { /class (\w+)/ && print "$1\n"; } close $IN; Of course the problem with this is that it ignores comments and string literals and it assumes that there will always be a single space between the "class" and the classname. Jenda ===== [EMAIL PROTECTED] === http://Jenda.Krynicky.cz ===== When it comes to wine, women and song, wizards are allowed to get drunk and croon as much as they like. -- Terry Pratchett in Sourcery -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>