By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,847 Members | 1,375 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,847 IT Pros & Developers. It's quick & easy.

Pease help me out with the program

P: 11
Expand|Select|Wrap|Line Numbers
  1. @sql = ('SV_userLogin.sql','sv_getDB_cmpCnt_r3m.sql','sv_getDB_cmpCnt.sql','sv_getDB_Corp_Trgt.sql','sv_getDB_score.sql','sv_getDB_Top25_cmpCnt.sql','sv_getDB_Top25_score.sql','sv_getOrgNameById.sql');
  2. my $prn;
  3. foreach ( @sql )
  4. {
  5.     my $line = $_;
  6.     if($line =~ s/^(\S+).sql$/$1/)
  7.     {
  8.         print "$line\n";
  9.         open(FILE,"c:/perl-scripts/sample.pl");
  10.         my @arr = <FILE>;
  11.         my $arrlines;
  12.         foreach ( @arr )
  13.         {
  14.            $arrlines = $_;
  15.             if($arrlines =~ /\$line/)
  16.             {
  17.                 #print $sqlname."\n";
  18.                 $prn .= "\n\t".$arrlines;
  19.             }
  20.         }
  21.     }
  22.  
  23. }
  24. print $prn;
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?
Mar 21 '08 #1
Share this Question
Share on Google+
7 Replies


KevinADC
Expert 2.5K+
P: 4,059
are you literally searching for $line?

Expand|Select|Wrap|Line Numbers
  1. if($arrlines =~ /\$line/)
if not, remove the backslash:

Expand|Select|Wrap|Line Numbers
  1. if($arrlines =~ /$line/)
Mar 21 '08 #2

P: 11
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
Mar 21 '08 #3

KevinADC
Expert 2.5K+
P: 4,059
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.
Mar 21 '08 #4

P: 11
Kevin,

Sorry for the inconvenience...

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

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

Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
  2. <html lang="en">
  3. <head>
  4.  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  5. </head>
  6. <font face="Arial">
  7. <h1>Alert.</h1>
  8. <p>Un-authorized access to Web Site.
  9. </p>
  10. </font>
  11. </html>
  12. HTML1
  13.  SV_userLogin($pgmId); # this is the stored procedure
  14.  
  15. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
  16. <html lang="en">
  17. <head>
  18.  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  19. </head>
  20. getDB_cmpCnt()
  21. <font face="Arial">
  22. <h1>Alert.</h1>
  23. <p>Un-authorized access to Web Site.
  24. </p>
  25. </font>
  26. </html>
  27. HTML1
from the serach it need to find the below lines and append those line in $prn SV_userLogin($pgmId); # this is the stored procedure
getDB_cmpCnt();
Mar 21 '08 #5

eWish
Expert 100+
P: 971
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 [code][/code] tags when posting code on this forum.

--Kevin
Mar 21 '08 #6

P: 11
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.
Mar 21 '08 #7

KevinADC
Expert 2.5K+
P: 4,059
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.
Mar 22 '08 #8

Post your reply

Sign in to post your reply or Sign up for a free account.