CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Regular Expressions:
Need help in regular exp

 



rayscosmic
New User

Mar 13, 2008, 12:16 AM

Post #1 of 7 (3442 views)
Need help in regular exp Can't Post

Hello i am new to perl.I have to write a script which should take a directory which contains .h and .c files. The script have to pass every .c file and find the functions/api in the file and insert a line after " { " and another line before return(if the function returns value) else before "}". can any1 help me in writing it??

Thanks & regards


KevinR
Veteran


Mar 13, 2008, 12:25 AM

Post #2 of 7 (3439 views)
Re: [rayscosmic] Need help in regular exp [In reply to] Can't Post

What have you got written so far?
-------------------------------------------------


rayscosmic
New User

Mar 13, 2008, 1:52 AM

Post #3 of 7 (3438 views)
Re: [KevinR] Need help in regular exp [In reply to] Can't Post

Not much...am just taking a folder... opening the file in it and checking for pattren match... but its not much working..

while($_ =<IN>){

if(/if|else|while/)

{
exit; }

else{

if( $_= /\W)$/)
{
if( $_= /\n/)
{
if($_= /^{/)
{
print ;

}

} }

its just a part of that pgm i have writen which i started to write today. Plz suggest me if u have any better idea or somthing else


rayscosmic
New User

Mar 13, 2008, 2:37 AM

Post #4 of 7 (3436 views)
Re: [KevinR] Need help in regular exp [In reply to] Can't Post

How to check for

function name(parameters)

{

Line1 i want to insert

...........

Line2 i want to insert

return (may be there or not)

}


KevinR
Veteran


Mar 13, 2008, 12:00 PM

Post #5 of 7 (3431 views)
Re: [rayscosmic] Need help in regular exp [In reply to] Can't Post

I was hoping you had much more code written. Is this school work?
-------------------------------------------------


rayscosmic
New User

Mar 16, 2008, 11:13 PM

Post #6 of 7 (3418 views)
Re: [KevinR] Need help in regular exp [In reply to] Can't Post

Hello kevin..

I am really very sorry.But i work in samsung india.I am not sure if i can post the entire code as my company is very strict in this.

And as i told i am new in perl and am not sure whether am doing it right way.I just hope u can give me some idea in this matter becoz the folder which contains .c & .h files is very big and there is no regular pattern to find out if it is a function or not. So if u could help me with it i would greatly appreciate.

Thanks & Regards


KevinR
Veteran


Mar 17, 2008, 11:32 AM

Post #7 of 7 (3412 views)
Re: [rayscosmic] Need help in regular exp [In reply to] Can't Post

Looks like you have some good suggestions over here:

http://www.daniweb.com/forums/thread113712.html

I am not familiar enough with C structure to help figure this out.
-------------------------------------------------

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives