| Author |
Message |
ivowel@gmail.com *nix forums beginner
Joined: 18 Jul 2005
Posts: 37
|
Posted: Fri Jun 16, 2006 3:41 pm Post subject:
Re: Text::Balanced to extract subs?
|
|
|
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
|
Posted: Fri Jun 16, 2006 4:26 am Post subject:
Re: Text::Balanced to extract subs?
|
|
|
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
|
Posted: Fri Jun 16, 2006 2:35 am Post subject:
Text::Balanced to extract subs?
|
|
|
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 |
|
 |
|