in reply to Another Challenge: Splitting data into chunks part2

If you have all of that text in $Info, then this would do what you want I think:
my %interface_to_desc= ($Info=~/interface\s+port-channel\s+(\d+).*?switchport\s+description\s ++To\s+(\S+)\s+/gs);
The hash interface_to_desc will then have the port-channel number as keys, and the text after description To as values.

Hope that helps. Oh, and have a look in the perlop manpage for how the g and s switch to regular expression works. Thats the whole secret here:-)

gc

Replies are listed 'Best First'.
Re^2: Another Challenge: Splitting data into chunks part2
by kwaping (Priest) on Sep 21, 2005 at 15:23 UTC
    Nice! (A ++ just wasn't enough.)