I am parsing a string in a subroutine that specifies a fixed number of parameters and two optional parameters. N.B. I also specify the parameter string being used.
This parameter string is of the form:
local_fs_name rem_fs_name timeout diff_limit hi hihi (rem_hi) (rem_hihi)
so definitely six parameters with two optional parameters for a max of eight.
Should the upper limit be set to the maximum number of parameters or one more than the maximum, i.e. eight or nine?
The only reasons to limit the number of fields
splitreturns that I can think of are either for efficiency purposes (and your subroutine would have to be called a lot with very many more parameters than required for this to matter) or if you really want to keep the separators in the final field.You shouldn’t be using
splitto verify the number of parameters. Fetch all of them into an array and then verify the contents of the array. Something like this: