To simulate a case construct use someting like:

/^[\t ]*$/ && do { print "blank\n" };

You just left out the "do".

Also check out Config::IniFiles http://search.cpan.org/search?dist=Config-IniFiles
for text-based config files. Haven't used it, but will as it looks very cool.

Matt


--- Filip Sneppe <[EMAIL PROTECTED]> wrote:
> Hi,
> 
> I have the following code to parse a config file:
> 
> my @section_headers = ("general", "database", "preprocessing",
> "postprocessing", "queries");
> 
> ....
> 
> while(<>)
>   {
>   /^[\t ]*$/ && { print "blank\n" };
>   /^[\t ]*#/ && { print "comment\n" };
> 
>   /\[.*\]/   &&
>     {
>     $config_section = (split (/[\[\]]/,$_))[1],
>     print $config_section ." \n",
> #    foreach $i (@section_headers)
> #      {
> #      $config_current_section = (lc($config_section) eq $i) ?
> $i:$config_current_section
> #      },
> #    die "config error - no valid section header\n" if
> ($config_current_section ne $config_section && $config_current_section ne
> "queries"),
> 
> #    for(my $x;$x<10;++$x) print "gg",
> 
>     print "in section $config_current_section -> $config_section\n"
>     };
> 
>   }
> 
> Now why am I getting syntax errors as soon as I uncomment either
> the foreach stuff, the die line, or the for loop.
> 
> I came accross the while loop and the "/(matches)/ && (commands)"
> when looking for a "select ... case" equivalent in perl, but I
> don't want to push every additional processing of $_ to subroutines
> and call them from the while loop...
> 
> Any help on how I can fix this ?
> 
> TIA,
> Filip
> 
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 


__________________________________________________
Do You Yahoo!?
Send FREE video emails in Yahoo! Mail!
http://promo.yahoo.com/videomail/

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to