Just another Perl shrine | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
Couple of high level thoughts (attempted with minimal caffeination, so take with large conglomeration of NaCL and I may be whiffing on template syntax a bit): This is almost complex enough you might want to look at using a proper parser (Parse::RecDescent, Marpa::R2) and build some sort of data structure to represent each "interface entry". Alternately maybe at least use "!\n" as your record separator and push the existing parsing logic off into its own sub (which then returns some sort of data structure . . .); doing that might help make sure you're not intermingling blocks and can (slightly more easily) start with a fresh parse state each one. Also rather than a bunch of hardcoded print statements for something like this I'd use Template Toolkit (see also Template) and write something which takes the data produced by the parsing bits and then passes those to something which expands into the final output lines.
The cake is a lie. In reply to Re: Cisco to Juniper - parser help
by Fletch
|
|