Re: regex and parsing config file directives..

2006-07-14 Thread Dr.Ruud
Rob Dixon schreef: > Dr.Ruud: >>>next if /^\s*$/; >> >> >> next if /^[[:blank:]]*$/ ; > > Why do you prefer /[[:blank:]]/ over /\s/ Ruud? [[:blank:]] is TAB + SP only (for ASCII). > I can't see the point > in treating CR, LF and FF as valid data. LF won't happen in this context ($ ma

Re: regex and parsing config file directives..

2006-07-14 Thread Rob Dixon
Dr.Ruud wrote: > next if /^\s*$/; next if /^[[:blank:]]*$/ ; Why do you prefer /[[:blank:]]/ over /\s/ Ruud? I can't see the point in treating CR, LF and FF as valid data. Anyway, I would prefer: next unless /\S/; which says it all. Rob -- To unsubscribe, e-mail: [EMAIL PROTEC

Re: regex and parsing config file directives..

2006-07-14 Thread John W. Krahn
Gregory Machin wrote: > Hi. Hello, > Sorry to bother No bother. :-) > but I can't get this script to work.. > It is supposed to parse the openvpn config, > 1) any line starting with a ";" is to be ignored > 2) all directives are written to a hash where the key is the directive and > the value

Re: regex and parsing config file directives..

2006-07-14 Thread Dr.Ruud
"Jeff Peng" schreef: > next if /^\s*#|^\s*;/; next if /^[[:blank:]]*[#;]/ ; > next if /^\s*$/; next if /^[[:blank:]]*$/ ; > my @array = split/\s+/; my @array = split ; Simpler would be to remove any blanks from the start end end of the line first: s/^[

Re: regex and parsing config file directives..

2006-07-14 Thread Gregory Machin
CTED]> >To: "Jeff Peng" <[EMAIL PROTECTED]> >CC: beginners@perl.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 &

Re: regex and parsing config file directives..

2006-07-14 Thread Jeff Peng
} = [EMAIL PROTECTED] || 'nodefined'; } From: "Gregory Machin" <[EMAIL PROTECTED]> To: "Jeff Peng" <[EMAIL PROTECTED]> CC: beginners@perl.org Subject: Re: regex and parsing config file directives.. Date: Fri, 14 Jul 2006 12:36:55 +0200 here is basic config

Re: regex and parsing config file directives..

2006-07-14 Thread Gregory Machin
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 119

Re: regex and parsing config file directives..

2006-07-14 Thread Jeff Peng
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 ? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additi

Re: regex and parsing config file directives..

2006-07-14 Thread Gregory Machin
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 ? On 7/14/06, Jeff Peng <[EMAIL PROTECTED]> wrote: Hello, Follow the conditions,the resolving way is not so complicated as yours.I would give my sample

RE: regex and parsing config file directives..

2006-07-14 Thread Jeff Peng
Hello, Follow the conditions,the resolving way is not so complicated as yours.I would give my sample way,hope it's useful to you. here is the config file's content: $ cat config.txt ;test file # comment lines IP = 1.2.3.4 PORT = 80 PREFORK_CHILDS = 5 MIN_SPARE_CHILDS here is

Re: regex and parsing config file directives..

2006-07-10 Thread Dr.Ruud
"Gregory Machin" schreef: > i'm using the follwing regex /(.+)[\s+\n](.+)/where $1 is the > directive and $2 is the option for the directive What is [\s+\n] supposed to mean? The \n is already in \s, so it is a characterset that holds everything \s holds, plus a plus sign. The construct sti

Re: regex and parsing config file directives..

2006-07-10 Thread Mumia W.
Mumia W. wrote: [...] if (m/^([\w-]+)(?: +(.*))?$/) { $directive{$1} = $2 || $1; } This is much more readable: my ($key, $value) = split /\s+/, $_, 2; $directive{$key} = $value || $key; -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Re: regex and parsing config file directives..

2006-07-10 Thread Mumia W.
Gregory Machin wrote: Hi I'm writing a script to pass a config file and put the values in a hash, with the key being the directive and the value bing the options, but some directives don't have options, so in that case i want to store the directive as the value so that for completeness.. i'm usi

Re: regex and parsing config file directives..

2006-07-10 Thread Mr. Shawn H. Corey
Gregory Machin wrote: > Hi > I'm writing a script to pass a config file and put the values in a hash, > with the key being the directive and the value bing the options, > but some directives don't have options, so in that case i want to store the > directive as the value so that for completeness..