rendler has asked for the wisdom of the Perl Monks concerning the following question:
Also the sites entry in the config file usually looks like thismy $sites_conf = "$ENV{'HOME'}/.newsboxes/sites.conf"; my %sites_config = parse_sites_config(); sub parse_sites_config { open SITES_CFG, "< $sites_conf" or die "Couldn't open $sites_conf: + $!\n"; my %options; while(<SITES_CFG>) { chomp; s/\/\/\s+.*//g; # Get rid of comments; next unless length; if (my($key, $operator, $value) = /^\s*?(\S+)\s*?(\=\>?)\s*?(\S+)\ +s*$/) { if ($operator eq "=>") { ++$options{'total_sites'}; $options{$options{'total_sites'}}{'site_name'} = $key; $options{$options{'total_sites'}}{'site_url'} = $value; } elsif ($operator eq "=") { $options{$options{'total_sites'}}{$key} = $value; } else { die "Ooops you might want to check $sites_conf for errors for +site: $options{$options{'total_sites'}}{'site_name'}\n"; } } } return %options; }
But sometimes such as for "Linux Today" it has the space in the site name and because I'm using \S+ to match that it's not working for those sites that have space(s) in their names. So I was wondering what I should be using instead. Thanks.Kuro5hin => http://www.kuro5hin.org key = k5 story_tag = item title_tag = title link_tag = link site_xml = http://www.kuro5hin.org/backend.rdf refresh = 1800 colour_1 = #302BA2 colour_2 = #FFFFFF colour_3 = #E0E0E0 colour_4 = #302BA2
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: A little config parsing.
by perrin (Chancellor) on Jan 11, 2002 at 08:59 UTC | |
by rendler (Pilgrim) on Jan 11, 2002 at 09:10 UTC | |
by cforde (Monk) on Jan 12, 2002 at 01:44 UTC | |
Re: A little config parsing.
by Chmrr (Vicar) on Jan 11, 2002 at 06:37 UTC | |
by rendler (Pilgrim) on Jan 11, 2002 at 08:05 UTC | |
by Chmrr (Vicar) on Jan 11, 2002 at 08:14 UTC | |
by rendler (Pilgrim) on Jan 11, 2002 at 08:39 UTC | |
by Chmrr (Vicar) on Jan 11, 2002 at 08:59 UTC | |
Re: A little config parsing.
by blokhead (Monsignor) on Jan 11, 2002 at 08:17 UTC |