Hi
I'm a newbie in PERL and wish to seek some help with regards to pattern
matching PERL and grep.
I would like the script to do the following:
1) List all *.java files containing following patterns:
double, parseDouble
2) Within such files, list all variables and declared as type "double" and
parseDouble(<variableName>)
e.g
Double fee, pfee, tot_bor_fee;
fee = fee + Double.parseDouble(p_fee) - Double.parseDouble(acc_fee);
tot_bor_fee = tot_bor_fee + Double.parseDouble(B_fee);
3) List appearance/lines with respect to the files having such variables.
i.e. output should be:
filename:
4) variables which have been explicitly converted to type double with the
function parseDouble() e.g
int x;
Double y = Double.parseDouble(x); ## variable x explicitly converted to type
double.
or
double y = (double)x; ## variable x explicitly converted to type double.
grep "double, parseDouble" /javadir/*.java
It however produces an error - I'm unable to pass multiple patterns for grep?
When I did:
$grep "parseDouble" /javadir/*.java
it produces a long output, which would be difficult for my project leader to
read.
I'd like the output to be something like:
<filename> <variable> <line>
src.java fee fee+=accrual
bak.java total total+=Double.parseDouble(x)
Could anyone help me out by showing an implementation of a PERL script to
automate this task? Attached is the Java source file, which is to be read as
the input.
Thanks
Danny
---------------------------------
Do you Yahoo!?
Yahoo! Mail - Find what you need with new enhanced search. Learn more.