Re: multidefine segfault

From: Laurent Bercot <ska-skaware_at_skarnet.org>
Date: Wed, 12 Apr 2017 05:18:27 +0000

>Is it possible to use one multidefine on a $line that gets an unknown
>number of words from stdin, then split it by one type of delimiter
>with the -r option (not knowing how many words it would get into
>$val). For instance, val might contain an unknown number of words.
>
>Then, I'd like to use a second multidefine or something like it to
>extract those words out of $val into separate variables. Is this
>possible?

  Forget about using a second multidefine, this is likely not what you
want.
  "multidefine -r" splits the value it reads:
  "multidefine -r $line { val }" would susbstitute $val with as many
words
as there are in $line. This is convenient when you want to read all the
words in $line, but not when you need to extract some of the words.

  multidefine is meant to provide equivalent functionality to the shell's
"read" command. Just like "read", it's good when you know the format of
your lines in advance; not so much with a variable format. If you need
to extract information from a variable format, I'd advise you to
process your line with standard utilities such as "cut", for instance.

  IF you want more precise help, you'll have to say exactly what you're
trying to accomplish, because it's not clear to me that your design is
sound.

--
  Laurent
Received on Wed Apr 12 2017 - 05:18:27 UTC

This archive was generated by hypermail 2.3.0 : Sun May 09 2021 - 19:38:49 UTC