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: Beginner: Re: [Laurent_R] How to extract string info from a bigger string: Edit Log



Zhris
Enthusiast

Apr 4, 2013, 11:29 AM


Views: 517
Re: [Laurent_R] How to extract string info from a bigger string

Vimo,

Your requirements are quite broad / open to intepretation. More specific detail may be required to provide the right solution.

Just to correct / extend Laurent's rough example:


Code
while (<>) {  
push @results, $1 if ( ( /^ce_pr_switch/ ... /^[^-]/ ) && ( /^-control_port \{ \w{3} (.+?) \}/ ) );
}


It uses the range operator to process blocks between line that begins with ce_pr_switch TO line that does not begin with - ( may be better to check for lines without backslash on end i.e. /[^\\] (\r|\n)*$/ ). This was to suit your requirement "whenever I encounter ce_pr_switch" assuming that there are multiple blocks per file / will ensure that we do not process isolated -control_port lines.

With regards to "goto check in all files", I can only assume you refer to checking all files across your entire system. File::Find will likely be suitable.

Chris


(This post was edited by Zhris on Apr 4, 2013, 11:58 AM)


Edit Log:
Post edited by Zhris (Enthusiast) on Apr 4, 2013, 11:30 AM
Post edited by Zhris (Enthusiast) on Apr 4, 2013, 11:38 AM
Post edited by Zhris (Enthusiast) on Apr 4, 2013, 11:41 AM
Post edited by Zhris (Enthusiast) on Apr 4, 2013, 11:42 AM
Post edited by Zhris (Enthusiast) on Apr 4, 2013, 11:58 AM


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

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