in reply to Regex Strikes again!

This snippet should give you the idea:
my $file="Finger.java"; my %comments=(); open(F,"<$file") or die "Can't open $file: $!"; while(defined($_=<F>)){ $comments{$.}=$_ if( m{...PUT THE MATCH YOU NEED HERE...} ); } close(F);

Reading the file line by line like I do has a drawback, though: you now need to take care yourself of multiline comments within /* ... */, and append to the correct string as needed.