Utter rubbish! It would take 3 times as long to work out how to do this use P::RD than with regexes--and that's if you understand recursive grammar definitions, perl references and that modules bewildering documentation.
I agree that the OP hasn't show much understanding of regexes, nor much willingness to learn, but pointing him at P::RD is just sadistic.
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
| [reply] |
Judging by the way the requirements have evolved and by OP's Re^2: Oracle report converter reply in his other relate thread, so far we have only seen the very tip of the iceberg - there is a lot more to come. Palming the OP off with a bunch of regexen solves a short term problem in a "look what I can do" fashion, but doesn't seem to be helping the OP very much at present and will lead to a maintenance nightmare for him in the longer term.
It is hard to know what the OP's motivation for this task is, but leading him along by offering tempting morsels that will either frustrate the OP because they don't provide all of the solution, or transfer a large development project over to PerlMonks, is unlikely to get the OP to a satisfactory endpoint. In fact, that's just sadistic. Much better to be up front and say "That's a big job. Here's the tool for it." and let the OP figure out sooner rather than later that either he's not up to it, or that some serious learning needs to be done. The nice thing is that this is a pretty good place to do a lot of that learning, or at least to get a lot of guidance toward appropriate learning resources.
DWIM is Perl's answer to Gödel
| [reply] |
Palming the OP off with a bunch of regexen solves a short term problem ... and will lead to a maintenance nightmare for him in the longer term.
Recursive Descent Parsers are great for recursive grammers, but this is self-evidently not a recursive grammar.
You have heard of Practical Extraction and Reporting Language perhaps? Yes, I know its a backronym, but this is bread & butter Perl usage. This is why the every other scripting language advertises itself as having a Perl Compatible Regex Engine.
... or transfer a large development project over to PerlMonks, ...
And you think that he isn't going to need help with P::RD? And isn't going to come back to PM for it?
If you are not interested in helping the guy, rather than preaching at him, move on. Somebody else will come along and be only too happy to help him. CountZero already posted a fairly comprehensive solution before you replied.
... he's not up to it, ...
Maybe he's not, but is that your call?
The nice thing is that this is a pretty good place to do a lot of that learning, or at least to get a lot of guidance toward appropriate learning resources.
I agree, but there is far greater pool of expertise in regex here than in P::RD. And given the OPs apparent expertise level, it will be far easier to educate him in the use of regex than P::RD, which requires a pretty full understanding of context free grammers to even get started. Not to mention that all but the most simple P::RD grammars seem require some use of regex, so he'd have to get to understand them anyway.
It seems his problem isn't likely to go away anytime soon:
Questioner: Dear all... I am willing to listen/read any advise at all. Maybe there
are tools out there that can help with this. If you know any please let me
know.
Reply: ... if that is really RPT/RPF, just throw away your programs.
Signature: ***** ****** Senior Oracle DBA.
... in a "look what I can do" fashion, but doesn't seem to be helping the OP very much at present ...
Ah! The crux. I am at least willing to try and help the guy help himself--though I'm asking him to make some effort--not just judge him as incompetent and "palm him off" with a pat PC reply.
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
| [reply] |
GrandFather!!
You said right .. I was going in a wrong way ..as You can understand I am not an expert perl programmer thats why I have started it that way...
As u suggested I am going through the Parse-RecDescent module .... So please tell me whether I can use this for
my .rpt file as well or not.. ?
| [reply] |
There are two things here: there seems to be no Perl tool that will provide a simple solution to your problem and, I suspect, that this task is rather beyond your current programming abilities. While we can provide various suggestions and even substantial code, at the end of the day you have to be able to assimilate that information and use it to complete your task.
There are many ways to solve your problem. The regular expression based approaches offered so far are appropriate for the the fairly straight forward parsing/extraction problem you have presented and in fact if that is the exetent of your task then it has already been solved for you. I suspect though that the problem as expressed is actually a small part of a larger project that may be better tackled with heavier duty tools, which is why I mentioned Parse::RecDescent. However more powerful tools generally require more work to understand and use.
If you provide us with the larger picture we may be able to suggest an alternative way of tacking the bigger issue rather generating more frustration for everyone by trying to solve parts of it piecemeal and out of context.
DWIM is Perl's answer to Gödel
| [reply] |