Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

Re: Parsing a config file

by thinker (Parson)
on Mar 10, 2005 at 16:39 UTC ( #438324=note: print w/replies, xml ) Need Help??

in reply to Parsing a config file

Hi tcf03

if your config file is always that simple, you could use a regex to parse it, like

#!/usr/bin/perl -l use strict; use warnings FATAL => "all"; my $stuff; { $/= undef; $stuff = <DATA>; } while ($stuff =~ /<server>\n(.*?)<\/server>/msg){ print join ",", split "\n", $1 ; } __DATA__ <server> printserver1 default cups cups </server> <server> printserver2 no aix rsh </server> __END__ this returns printserver1,default,cups,cups printserver2,no,aix,rsh

If it can get much more complicated than this, you may have to consider alternatives

I hope this helps


Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://438324]
[Discipulus]: [OT] if i have an svg image (a map of italian provinces) like this one in which way i need to interact with it to have a geochart?
[Corion]: I haven't found a good way to plot stuff into country maps... Maybe one of the demos of D3.js has something usable?
[Discipulus]: i need to use css to get and colorize various different IDs?
[Corion]: I haven't used it, but http://datamaps. looks promising
[Discipulus]: thanks.. a more perlish solution?

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (11)
As of 2017-03-23 09:20 GMT
Find Nodes?
    Voting Booth?
    Should Pluto Get Its Planethood Back?

    Results (285 votes). Check out past polls.