pointer: a value that refers to another object non-null-pointer: a pointer whose value is not zero string: a sequence of characters in format F sp: a pointer to a string nnsp: a non-null-pointer to a string boolean: TRUE | FALSE boolean strcmp (nnsp a, nnsp b): takes two non-null string pointers and returns TRUE if the strings are equal #### sp x, y; boolean b; b = strcmp (x,y); #### create a data structure filled with default values known to conform to the required assertions. collect the input that will instantiate this structure. iterate over the input { if (this input is valid) { put the input into the structure. } else { put a conforming error value into the structure. } } ## at this point, we can assume that the structure conforms ## to the assertions, whether the input was valid or not #### %templates = ( 1 => "template one: data = #DATA#", 2 => "template two: data = #DATA#", 3 => "template three: data = #DATA#", ERR => "bad template reference, but the data = #DATA#", ); %data = ( 1 => "data value 1", 2 => "data value 2", 3 => "data value 3", ERR => "bad data reference" ); for (1..20) { $t = $templates{ int rand(5) } || $templates{'ERR'}; ## assertion: we always get a template that will be usable ## in the substitution below. $d = $data{ int rand(5) } || $data{'ERR'}; ## assertion: we always get a value that will be usable ## in the substitution below. $t =~ s/#DATA#/$d/; print $t, "\n"; }