a regular expression without the =~ operator tests the $_ scalar. but it seems that you intended $line to hold each lines of the java source code. if that is not true, forget my posting... ;)
you can use (nearly) any other character as delimiters to regular expressions. that is sometimes useful if the slash is to be matched against, for example: