If I declared a variable $myString with the value \'3 \' (notice the white space).
Is there any function to remove the white space for the return v
Just looking over your program, I found 3 spots that could be improved or fixed.
I apologize if my code doesn't format well. :-(
In your function parse_block(...), there are 3 items that need attention.
@attribs = $attribs =~ /\s*(\w+\s+=\s+\w+\s+|\w+\s+=\s+".*?"|\w+\s+=\s+<.*?>)\s*/g;
To eliminate the white space after vid => '6 ', just don't include the \s+ at the end of your first sub-regex.
Write it as:
@attribs = $attribs =~ /\s*(\w+\s+=\s+\w+|\w+\s+=\s+".*?"|\w+\s+=\s+<.*?>)\s*/g;
$value = [ parse_type_value_specifier( $start_tail ) ];
You want this instead:
$value = [ parse_type_value_specifier( $value ) ];
(Note that the parameter to the function should be $value and not $start_tail.) You probably didn't notice this.
In the loop for @attributes, the 'else' in the if/else condition excutes when the 'value' has a plain value, (no "" or <...> items in 'value').
Update: Changed parameter in
parse_type_value_specifier(...)to $value. It was (incorrectly) stated as $attrib.