I have a huge java codebase (more than 10,000 java classes) that makes extensive use of CORBA (no documentation available on its usage though).
As first step to figure out the CORBA usage, I decided to scan entire codebase and extract/print unique lines which contain the pattern “org.omg.CORBA“. These are usually in the import statements (e.g. import org.omg.CORBA.x.y.z).
I am newbie to Perl and want to know if there is a way I can extract these details on Windows OS. I need to be able to scan all folders (and sub-folders) that have java classes.
You can use File::Find in a one-liner:
Note that this one-liner is using the double quotes required for Windows.
This will search the current directory recursively for files with extension
.javaand add them to the@ARGVarray. Then we use the diamond operator to open the files and search for the stringorg.omg.CORBA, and if it is found, that line is added as a key to the%seenhash, which will effectively remove duplicates. The last statement prints out all the unique keys in the hash.In script form it looks like this: