in reply to Re^7: Converting Oracle report language code into perl
in thread Converting Oracle report language code into perl

This node falls below the community's threshold of quality. You may see it by logging in.
  • Comment on Re^8: Converting Oracle report language code into perl

Replies are listed 'Best First'.
Re^9: Converting Oracle report language code into perl
by BrowserUk (Patriarch) on Jun 27, 2007 at 09:49 UTC
      yeah I know ...here my code
      $ARGV[0] .= ".rpt"; open(FH,"<$ARGV[0]") or die "Cant open"; @arr = <FH>; close(FH); foreach $data(@arr){ if($data =~ /^\.define/ .. /^\.\.\.define$/){ $data =~ s/(^\.\w+\s+)(\w+)(\s+)(.+\w+$)(\s+\. \.$)/$2,$4/smx; print "$data \n"; } }
      and I am getting the output like this
      .define lok_tabs lock tab book_tab, book_mat, custdata2, ed_tab, book_rates, print_tab in share update mode .. .define get_input select key, key1, key2, key3, key4, print_name into input_book_seq, fax_head, file_num, in_print_rates, NotId, print_name from ed_table where ed_table.tag = 'BOOK' and ed_table.key = 'PRNT' and ed_table.user_id = user ..
      u can see I am not able to capture the data between .define and .. properly using the regex..PLease help me out

        When you did @arr = <FH>;, you broke your file into an array of lines. One per array element.

        When you do foreach $data(@arr){, you are setting $data to each of those lines in turn. Ie. $data will only ever contain one line at a time.

        So, when you do $data =~ s/(^\.\w+\s+)(\w+)(\s+)(.+\w+$)(\s+\. \.$)/$2,$4/smx;, which is attempting to match this:

        .define lok_tabs lock tab book_tab, book_mat, custdata2, ed_tab, book_rates, print_tab in share update mode ..

        which is spread over 4 lines, it will always fail.

        How could it match 4 lines in one line?

        Do you have any ideas for how you might get around this problem?


        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.