ewhitt has asked for the wisdom of the Perl Monks concerning the following question:
------- Sample Text ------- ! interface Ethernet blah... blah... ! interface Gigabit blah... blah... ! interface Ethernet blah... ! ------- Sample Text -------
foreach $line (@cfg) { if ($line =~ m/^interface (\.*)/) { if ($1 eq "Ethernet") { &parse_ethernet($1); Keep parsing until $line matches "!" } if ($1 eq "Gigabit") { &parse_gigabit($1); Keep parsing until $line matches "!" } } if ($line =~ m/^system (\.*)/) { blah... } }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Need advice on how to break foreach parsing loop into functions
by Anno (Deacon) on Sep 15, 2007 at 15:21 UTC | |
by Prof Vince (Friar) on Sep 16, 2007 at 08:36 UTC | |
by Anonymous Monk on Sep 16, 2007 at 17:22 UTC | |
Re: Need advice on how to break foreach parsing loop into functions
by quester (Vicar) on Sep 15, 2007 at 20:56 UTC |