Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: match multi-lines from config file

by xicheng (Sexton)
on Aug 07, 2007 at 04:28 UTC ( [id://630949]=note: print w/replies, xml ) Need Help??


in reply to match multi-lines from config file

An easy way for this kind of problems is to reset the IRS $/, say:
use strict; use warnings; use Data::Dumper; my %hash = (); { local $/ = "interface "; while(<DATA>) { my ($key) = /description\s+(.*)/; next if $key =~ /^\s*$/; my ($value) = /switchport trunk allowed vlan\s*(.*)/; $hash{$key} = $value; } print Dumper \%hash; __DATA__ .....
Make sure the IRS won't show up within each block, so make it more specific accordingly...
Regards,
Xicheng

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://630949]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (3)
As of 2024-04-25 20:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found