niXforums Forum Index
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   PreferencesPreferences   Log in to check your private messagesLog in to check your private messages   Log inLog in 
·  nixdoc.net ·  man pages ·  Linux HOWTOs ·  FreeBSD Tips ·  Forums
navigation Forum index » Programming » Perl » modules
Text::Balanced to extract subs?
Post new topic   Reply to topic Page 1 of 1 [3 Posts] View previous topic :: View next topic
Author Message
ivowel@gmail.com
*nix forums beginner


Joined: 18 Jul 2005
Posts: 37

PostPosted: Fri Jun 16, 2006 3:41 pm    Post subject: Re: Text::Balanced to extract subs? Reply with quote

Sorry, the pattern for a valid subname was just there for illustration.
I am stuck on how to extract multiple consecutive subroutines that
have nested parens:
# others
sub a { if (0==0) { print "hi"; } }
# more others
sub b{ if (1==0) { print "hi"; } }

regards,

/iaw
Back to top
Ch Lamprecht
*nix forums addict


Joined: 26 Jan 2006
Posts: 55

PostPosted: Fri Jun 16, 2006 4:26 am    Post subject: Re: Text::Balanced to extract subs? Reply with quote

ivowel@gmail.com wrote:
Quote:
dear perl users: I want to write a function that extracts "ordinary"
subroutines from perl code. (an equivalent task is extracting all
macros from a latex file.) I am not trying to be too clever. let's
presume I can recognize subs because subs and only subs always start at
the first character of a line and are not anonymous. a sub is followed
by a name and can contain nested expressions.

I can do plain pattern matching to find the first occurance of the
first sub: '^sub [a-zA-Z]+'. but now I am stuck. I need to continue

sub my_1st_sub_not_recognized {};
\w = a word character

Christoph




--

perl -e "print scalar reverse q/ed.enilno@ergn.l.hc/"
Back to top
ivowel@gmail.com
*nix forums beginner


Joined: 18 Jul 2005
Posts: 37

PostPosted: Fri Jun 16, 2006 2:35 am    Post subject: Text::Balanced to extract subs? Reply with quote

dear perl users: I want to write a function that extracts "ordinary"
subroutines from perl code. (an equivalent task is extracting all
macros from a latex file.) I am not trying to be too clever. let's
presume I can recognize subs because subs and only subs always start at
the first character of a line and are not anonymous. a sub is followed
by a name and can contain nested expressions.

I can do plain pattern matching to find the first occurance of the
first sub: '^sub [a-zA-Z]+'. but now I am stuck. I need to continue
on with a Text::Balanced expression right after, and after the
text::balanced is done, continue on with my regex search (\G).

this must be a very common problem. is Text::Balanced the right module
for the task? if so, can someone please point me to a simple example?

sincerely, /iaw
Back to top
Google

Back to top
Display posts from previous:   
Post new topic   Reply to topic Page 1 of 1 [3 Posts] View previous topic :: View next topic
The time now is Fri Jan 09, 2009 10:16 pm | All times are GMT
navigation Forum index » Programming » Perl » modules
Jump to:  

Similar Topics
Topic Author Forum Replies Last Post
No new posts Oracle Text Score Computation jatinder.1975@gmail.com Server 0 Fri Jul 21, 2006 1:00 pm
No new posts FAQ 4.34 How do I extract selected columns from a string? PerlFAQ Server Perl 0 Fri Jul 21, 2006 7:03 am
No new posts PIL - transparent ImageDraw.text() aljosa python 1 Wed Jul 19, 2006 3:43 pm
No new posts user supplied forum text and htmlentities Sandy.Pittendrigh@gmail.c PHP 1 Wed Jul 19, 2006 2:19 pm
No new posts text representation of HTML Ksenia Marasanova python 5 Wed Jul 19, 2006 10:09 am

Loans | NFL Talk Football Forums | Refinance | Bankruptcy | Mortgage Calculator
Copyright © 2004-2005 DeniX Solutions SRL
 
Other DeniX Solutions sites: Unix/Linux blog |  electronics forum |  medicine forum |  science forum | 
Privacy Policy


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.1547s ][ Queries: 20 (0.0823s) ][ GZIP on - Debug on ]