in reply to Is a here-doc a good way to retrieve data file contents for testing?

That's how I'd do it.

Purely out of esthetical reasons

use strict; use warnings; print "-------\n"; print json_here(); print "-------\n"; sub chompit { my $str = shift; chomp $str; return $str; } sub json_here { chompit << '__JSON__' ; "Type": 0, "Width": 504, "X": 18, "Y": 18 } ] } __JSON__ }

update

changed END_JSON to __JSON__

Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery

Replies are listed 'Best First'.
Re^2: Is a here-doc a good way to retrieve data file contents for testing? (updated)
by Lotus1 (Vicar) on Jan 18, 2021 at 01:14 UTC

    I like your suggestion to not use 'END' at the start of the here-doc. Showing the format is a great idea. This made me wonder what would happen if I used '__DATA__'. It actually worked!