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 is the value of the directive . > 3) if the directive is present but no value is set then the key must be set > to the directive and the value must be set to "defined" or the same > value as > the key.. This may work for you (UNTESTED): #!/usr/bin/perl use warnings; use strict; print "opening config file for processing\n\n"; open IN, '<', '/etc/openvpn/client.conf' or die "Cannot open '/etc/openvpn/client.conf' $!"; my %directive; while ( <IN> ) { next if /^[#;]/ or not /\S/; my ( $key, $value ) = split; $directive{ $key } = $value || 1; } print ">>>>>>>>>>>>>>>\n\n"; for my $key ( keys %directive ) { print "$key => $directive{$key}\n"; } __END__ John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>