Pease help me out with the program

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • getmadhu
    New Member
    • Mar 2008
    • 11

    Pease help me out with the program

    [CODE=perl]@sql = ('SV_userLogin. sql','sv_getDB_ cmpCnt_r3m.sql' ,'sv_getDB_cmpC nt.sql','sv_get DB_Corp_Trgt.sq l','sv_getDB_sc ore.sql','sv_ge tDB_Top25_cmpCn t.sql','sv_getD B_Top25_score.s ql','sv_getOrgN ameById.sql');
    my $prn;
    foreach ( @sql )
    {
    my $line = $_;
    if($line =~ s/^(\S+).sql$/$1/)
    {
    print "$line\n";
    open(FILE,"c:/perl-scripts/sample.pl");
    my @arr = <FILE>;
    my $arrlines;
    foreach ( @arr )
    {
    $arrlines = $_;
    if($arrlines =~ /\$line/)
    {
    #print $sqlname."\n";
    $prn .= "\n\t".$arrline s;
    }
    }
    }

    }
    print $prn;[/CODE]

    In the above program its not printing the lines which contain the <sqlname> from the sample.pl programs.

    Can any one please help me where I have done the wrong?
    Last edited by eWish; Mar 21 '08, 08:38 PM. Reason: Please use [code][/code] tags
  • KevinADC
    Recognized Expert Specialist
    • Jan 2007
    • 4092

    #2
    are you literally searching for $line?

    Code:
    if($arrlines =~ /\$line/)
    if not, remove the backslash:

    Code:
    if($arrlines =~ /$line/)

    Comment

    • getmadhu
      New Member
      • Mar 2008
      • 11

      #3
      Thanks Kevin for looking into it...

      Actually I am not comparing the complete line with the array

      In the file each line contains set of words with in that I am searching the array element is present in that line or not

      I hope Kevin that u had an idea what I am looking for....

      Thank you

      Comment

      • KevinADC
        Recognized Expert Specialist
        • Jan 2007
        • 4092

        #4
        Originally posted by getmadhu
        Thanks Kevin for looking into it...

        Actually I am not comparing the complete line with the array

        In the file each line contains set of words with in that I am searching the array element is present in that line or not

        I hope Kevin that u had an idea what I am looking for....

        Thank you
        Post an example of the file and what you are searching for. Your explanation is hard to understand.

        Comment

        • getmadhu
          New Member
          • Mar 2008
          • 11

          #5
          Kevin,

          Sorry for the inconvenience.. .

          This is the sample file which the array is searching whether element is presentor not

          sample.pl
          ----------------

          Code:
          <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
          <html lang="en">
          <head>
           <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
          </head>
          <font face="Arial">
          <h1>Alert.</h1>
          <p>Un-authorized access to Web Site.
          </p>
          </font>
          </html>
          HTML1
           SV_userLogin($pgmId); # this is the stored procedure
          
          <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
          <html lang="en">
          <head>
           <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
          </head>
          getDB_cmpCnt()
          <font face="Arial">
          <h1>Alert.</h1>
          <p>Un-authorized access to Web Site.
          </p>
          </font>
          </html>
          HTML1
          from the serach it need to find the below lines and append those line in $prn SV_userLogin($p gmId); # this is the stored procedure
          getDB_cmpCnt();
          Last edited by eWish; Mar 21 '08, 08:39 PM. Reason: Please use [code][/code] tags

          Comment

          • eWish
            Recognized Expert Contributor
            • Jul 2007
            • 973

            #6
            What you posted was the HTML. Where is the perl code? You can't just embed the perl code inside of the HTML, unless you are using a templating system that enables you to do so.

            Also, please use the &#91;code]&#91;/code] tags when posting code on this forum.

            --Kevin

            Comment

            • getmadhu
              New Member
              • Mar 2008
              • 11

              #7
              Hi eWish...


              This is what I am looking for....

              From the scrap perl code @sql array which contains set of elements. those elements need to loop and search in a file sample.pl to find out for the @sql elements located in the perl file or not. If they regular expression satisfies and found the @sql elements from the sample.pl (instead of text file, I am searching perl files) those lines need to append $prn and later it need to print those matched lines.

              But up to looping its working fine... after that when I am searching $sqlname in file file it is not showing up. Can you please help me where I went wrong.

              Comment

              • KevinADC
                Recognized Expert Specialist
                • Jan 2007
                • 4092

                #8
                Originally posted by getmadhu
                Hi eWish...


                This is what I am looking for....

                From the scrap perl code @sql array which contains set of elements. those elements need to loop and search in a file sample.pl to find out for the @sql elements located in the perl file or not. If they regular expression satisfies and found the @sql elements from the sample.pl (instead of text file, I am searching perl files) those lines need to append $prn and later it need to print those matched lines.

                But up to looping its working fine... after that when I am searching $sqlname in file file it is not showing up. Can you please help me where I went wrong.
                Remove the backslash like I already suggested.

                Comment

                Working...