1999 twenty-four merry days of Perl Feed

Testing Heredocs

perl - 1999-12-05

Heredocs inside begin/end

if( ... ) {
    my $string = <<'HERE';
This string is flush left!
Here's another line!
This is insane!
HERE

...
}

Here docs indented inside begin/end

if( ... ) {
    my $string = <<~'HERE';
This string is outdented!
        Here's another line!
        This is nicer!
HERE

    ...
}

Here docs in indented lines

    if( ... ) {
        my $string = <<'HERE';
    This string is flush left!
    Here's another line!
    This is insane!
    HERE

        ...
    }

Here docs indented in indented lines

    if( ... ) {
        my $string = <<~'HERE';
            This string is outdented!
            Here's another line!
            This is nicer!
            HERE

        ...
    }

Here docs with syntax-highlighted from shebang in indented lines

if( ... ) {
    my $string = <<'HERE';
This string is flush left!
Here's another line!
This is insane!
HERE

    ...
}

Here docs indented with syntax-highlighted from shebang in indented lines

if( ... ) {
    my $string = <<~'HERE';
This string is outdented!
        Here's another line!
        This is nicer!
HERE

    ...
}

Here docs in verbatim begin code

if( ... ) {
    my $string = <<'HERE';
This string is flush left!
Here's another line!
This is insane!
HERE

    ...
}

Here docs indented in verbatim begin code

if( ... ) {
    my $string = <<~'HERE';
        This string is outdented!
        Here's another line!
        This is nicer!
        HERE

    ...
}

Here docs with syntax-highlighted from shebang in indented lines (vim)

if( ... ) {
    my $string = <<'HERE';
This string is flush left!
Here's another line!
This is insane!
HERE

    ...
}

Here docs indented with syntax-highlighted from shebang in indented lines (vim)

if( ... ) {
    my $string = <<~'HERE';
This string is outdented!
Here's another line!
This is nicer!
HERE

    ...
}

Here docs with begin vim

if( ... ) {
    my $string = <<'HERE';
This string is flush left!
Here's another line!
This is insane!
HERE

    ...
}

Here docs indented with begin vim

if( ... ) {
    my $string = <<~'HERE';
This string is outdented!
Here's another line!
This is nicer!
HERE

    ...
}
Gravatar Image This article contributed by: Thibault DUPONCHELLE <thibault.duponchelle@gmail.com>