Perl

NAVIGATION
CATEGORIES
REFERRENCE
LINKS
  • regex and parsing config file directives..

    0 answers - 2149 bytes - related search similar search Add To My Delicious Add To My Stumble Upon Add To My Google Mark Add To My Facebook Add To My Digg Add To My Reddit

    Since there are the parameters which have multi-values,you could store the
    values in an array and use this array's reference as hash's value.For
    example:
    while(<HD>){
    next if /^\s*#|^\s*;/;
    next if /^\s*$/;
    my @array = split/\s+/;
    my $key = shift @array;
    $hash{$key} = \@array || 'nodefined';
    }

    >From: "Gregory Machin" <gregory.machin (AT) gmail (DOT) com>
    >To: "Jeff Peng" <peng (AT) dig-tech (DOT) com>
    >CC: beginners (AT) perl (DOT) org
    >Subject: Re: regex and parsing config file directives
    >Date: Fri, 14 Jul 2006 12:36:55 +0200
    >
    >here is basic config
    >All lines starting with ; or # are to be regarded as commented out as
    >are ignored
    >
    >client some of the directives are set jst by there
    >pressence
    >;dev tap
    >dev tun0
    >;dev-node MyTap
    >proto tcp
    >;proto udp
    >remote 192.168.1.1 1194
    >;remote my-server-2 1194
    >;remote-random
    >resolv-retry infinite
    >nobind
    >;user nobody
    >;group nobody
    >persist-key
    >persist-tun
    >;http-proxy-retry # retry on connection failures
    >;http-proxy [proxy server] [proxy port #]
    >;mute-replay-warnings
    >ca ca.crt
    >cert greg.crt
    >key greg.key
    >;ns-cert-type server
    >;tls-auth ta.key 1
    >cipher AES-128-CBC
    >comp-lzo
    >verb 3
    >;mute 20
    >
    >

    7/14/06, Jeff Peng <peng (AT) dig-tech (DOT) comwrote:
    >>
    >>
    >>Could you paste your config file here?Then we could look at the situation
    >>more clearly.
    >>
    >>
    >>looks good but my configs don't us "=" there is just a space so
    >>could
    >>one use my ($key,$value) = split/\ /; to split the kay and the value ?
    >>
    >>
    >>

    >
    >


    >Gregory Machin
    >gregory.machin (AT) gmail (DOT) com
    >www.linuxpro.co.za

Re: regex and parsing config file directives..


max 4000 letters.
Your nickname that display:
In order to stop the spam: 7 + 6 =
QUESTION ON "Perl"

EMSDN.COM