Hi Experts,
Here's an URGENT need for a PERL programme.
I post it for 300 points.
Pls kindly help. Thanks.
Requirement
===========
(1) Syntax :- smartgrep.pl -type [opt]
where "-type" is a switch
(2) Description of usage :-
The PERL scripts must be able to selectively grep lines from a file, based on the [opt] used, then save the lines into a new file.
The usage can be best descripted by the following example.
For example :-
I have a file called "original", which contains a lot of lines that look like the following :-
(This file can contain up to > 50000 lines)
0 EQ /apple/min_abcde/a
0 UI /grapes/u123/c
0 UO /ppsseqs/u300/a
1 UO /aasflwctls/u9008/a
1 UO /aasseqs/min_u2354/a
0 UO /aasseqs/u712/b
1 UO /aasseqs/u949/b
1 EQ /ffsseqs/u805/o
0 EQ /ffsseqs/u805/a
0 EQ /sssques/min_u808/b
0 UO /ssques/u35/c
0 EQ /sssques/min_u807/o
1 EQ /sssques/min_u807/a
1 EQ /sssques/min_u807/b
0 UO /sssques/u35/b
....... (so on ...)
Basically, there are few terms that are important in the "original" file,
i.e. "UC", "UO", "AU", "UI" and "EQ"
The first four are the main terms.
When I run the "smartgrep.pl" with the following syntax :
prompt> smartgrep.pl -type UO
the script should be able to grep the lines in the "original" file with terms "UO"
AND also lines with "EQ" that comes only after the first "UO" terms.
Then, all the lines that are grepped will be written into a file called "UO.log".
And if next I run the syntax as follow :
prompt> smartgrep.pl -type AU
Of course the script should be able to grep all the lines with "AU" terms
AND also lines with "EQ" terms that come only after the first "AU" terms.
Then, all the lines that are grepped will be written into a file called "AU.log".
Pls kindly help as this is needed URGENTLY.
Thanks.
Start Free Trial