> For the complete documentation index, see [llms.txt](https://trizen.gitbook.io/sidef-lang/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://trizen.gitbook.io/sidef-lang/programming_tasks/r/read_a_configuration_file.md).

# Read a configuration file

```ruby
var fullname = (var favouritefruit = "")
var needspeeling = (var seedsremoved = false)
var otherfamily = []
 
ARGF.each { |line|
    var(key, value) = line.strip.split(/\h+/, 2)...
 
    given(key) {
        when (nil)              { }
        when (/^([#;]|\h*$)/)   { }
        when ("FULLNAME")       { fullname = value }
        when ("FAVOURITEFRUIT") { favouritefruit = value }
        when ("NEEDSPEELING")   { needspeeling = true }
        when ("SEEDSREMOVED")   { seedsremoved = true }
        when ("OTHERFAMILY")    { otherfamily = value.split(',')»strip()» }
        default                 { say "#{key}: unknown key" }
    }
}
 
say "fullname       = #{fullname}"
say "favouritefruit = #{favouritefruit}"
say "needspeeling   = #{needspeeling}"
say "seedsremoved   = #{seedsremoved}"
 
otherfamily.each_kv {|i, name|
    say "otherfamily(#{i+1}) = #{name}"
}
```

#### Output:

```
fullname       = Foo Barber
favouritefruit = banana
needspeeling   = true
seedsremoved   = false
otherfamily(1) = Rhu Barber
otherfamily(2) = Harry Barber
```
