# Parsing one or more networks in ConfParser

**URL:** <https://discourse.julialang.org/t/parsing-one-or-more-networks-in-confparser/134838>\
**Category:** General Usage\
**Tags:** configuration\
**Created:** [January 2, 2026, 6:31am UTC](https://discourse.julialang.org/t/parsing-one-or-more-networks-in-confparser/134838 "2026-01-02T06:31:12Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![phma](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/phma/32/6576_2.png) [@phma](https://discourse.julialang.org/u/phma)\
**Post date:** [January 2, 2026, 6:31am UTC](https://discourse.julialang.org/t/parsing-one-or-more-networks-in-confparser/134838/1 "2026-01-02T06:31:12Z")

</div>

I’m writing a config file parser `using ConfParser` for a config file which includes, among other things, the latitude, longitude, and networks from which clients may connect. The file looks like this:

```julia-auto
Latitude 35.snip
Longitude -81.snip
ClientNet puma/24,puma/64

```

`puma` is the computer I’m running this on, and both IPv4 (192.168.1.0/24) and IPv6 netblocks are allowed to connect. Someone may have only one netblock that may connect. Here’s the code:

```julia-auto
"""
    getLatitude()

Gets the latitude from a configuration file. The latitude should be written
in degrees with decimals or degrees:minutes:seconds.
"""
function getLatitude()
  ret=NaN
  for c in confs()
    str=retrieve(c,"Latitude")
    try
      ret=dms2rad(str)
    catch
    end
  end
  ret
end

"""
    getLongitude()

Gets the longitude from a configuration file. The longitude should be written
in degrees with decimals or degrees:minutes:seconds.
"""
function getLongitude()
  ret=NaN
  for c in confs()
    str=retrieve(c,"Longitude")
    try
      ret=dms2rad(str)
    catch
    end
  end
  ret
end

# snip parseNetblock(str::String) -> Vector{IPNet}

function getClientNet()
  ret=IPNet[]
  for c in confs()
    str=retrieve(c,"ClientNet")
    if str>""
      nets=split(str,',')
      for net in nets
	try
	  append!(ret,parseNetblock(net))
	catch
	end
      end
    end
  end
  ret
end

```

This gave an error at `if str>""` because `str` is not a `String` but a `Vector{String}`. So I tried retrieving the lines from the configuration. I got this:

```julia-auto
julia> retrieve(EAConfig.confs()[1],"ClientNet")
2-element Vector{String}:
 "puma/24"
 "puma/64"

julia> retrieve(EAConfig.confs()[1],"Latitude")
"35.snip"

```

I then tried `retrieve` with a type argument:

```julia-auto
julia> retrieve(EAConfig.confs()[1],"ClientNet",String)
ERROR: MethodError: no method matching parse(::Type{String}, ::Vector{String})
julia> retrieve(EAConfig.confs()[1],"Latitude",Vector{String})
ERROR: MethodError: no method matching parse(::Type{Vector{String}}, ::String)

```

How do I either get the string including the comma, or get a vector of strings, with only one string in the vector if there is no comma?

I’m going to temporarily have two `ClientNet` lines, but I’d rather have just one.

---

<div class="post-metadata">

**Author:** ![phma](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/phma/32/6576_2.png) [@phma](https://discourse.julialang.org/u/phma)\
**Post date:** [January 4, 2026, 7:28am UTC](https://discourse.julialang.org/t/parsing-one-or-more-networks-in-confparser/134838/2 "2026-01-04T07:28:32Z")

</div>

Two `ClientNet` lines did not work. I ran this command:

```julia-auto
julia> @edit retrieve(confs()[1],"ClientNet")

```

Looking at the source code, I made this change:

```julia-auto
nets=c._data["ClientNet"]

```

Now it works. It may be broken by a future version of `ConfParser` though.
