Skip to content
This repository was archived by the owner on Nov 8, 2024. It is now read-only.
This repository was archived by the owner on Nov 8, 2024. It is now read-only.

perl template generates code with syntax errors and quoting issues #39

@yargevad

Description

@yargevad

JSON objects translated to Perl hash references use : as the separator instead of , or =>, which causes syntax errors.

There can be unbalanced braces in generated code, which causes syntax errors.

JSON containing embedded newlines is single quoted, which double escapes the newlines, causing literal \n characters to appear in embarrassing places. This can be avoided by using qq'...' or regular double quotes instead of single quotes, however that will trigger Perl's string interpolation on the entire string, so it might be necessary to only double quote the newlines:

my $hr = {
  'abc' => 'def' ."\n". 'ghi',
};

In order to see this in action, head over to the SparkPost API docs, click the < on the black background near the top right hand corner, click Create Transmission with Inline Parts Content, and scroll down to select Perl from the language dropdown.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions