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
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
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
"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/^[
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
&
} = [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
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
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
__END__
Run it and get the result output:
$ perl test.pl
$VAR1 = {
'PREFORK_CHILDS' => '5',
'IP' => '1.2.3.4',
'MIN_SPARE_CHILDS' => 'nodefined',
'PORT' => '80'
#x27;nodefined',
'PORT' => '80'
};
From: "Gregory Machin" <[EMAIL PROTECTED]>
To: beginners@perl.org
Subject: regex and parsing config file directives..
Date: Fri, 14 Jul 2006 11:18:40 +0200
Hi.
Sorry to bother but I can't get this s
Hi.
Sorry to 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 is the value of the directive .
3) if the directive is prese
"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
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]
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
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..
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 using the follwing regex /
16 matches
Mail list logo