Skip to content

Instantly share code, notes, and snippets.

View perlpunk's full-sized avatar

Tina Müller (tinita) perlpunk

View GitHub Profile
#!/usr/bin/env perl
use strict;
use warnings;
use 5.010;
use JSON ();
use JSON::PP ();
use JSON::XS ();
use Cpanel::JSON::XS ();
use Mojo::JSON ();
key: long
value
split
into
several
lines
for
readability
key: "long
value
[
{
"type": "sequence",
"elements": [
{
"type": "int",
"value": "42"
},
]
},
---
- &1
links:
- &2
links:
- *1
name: B
- &3
links:
- *1
use YAML;
use Data::Dumper;
my $yaml = <<"EOM";
--- !!perl/hash:Foo
b: B
a: A
EOM
my $data = Load $yaml;
say Dumper $data;
say Dump $data;
# 1.-3.: the resulting tag of a merged list or mapping will be the tag of the first item of the !!merge
--- # 1. set object tag in defaults
default-article: !article &defaults
foo: bar
theme: default-theme
article: !!merge
- *defaults
- theme: my-cool-theme
author: myself
- name: run a command and save lines
command: ls -l *.yaml
register: files
- name: copy files
copy:
src: "{{ item }}"
dest: /path/{{ item }}
with_items: files.stdout_lines
---
a:
b: &1
abcde: &2
- fghi
- jklm
- &3
nopq: rstu
c:
- *1
<html>
<head>
<title>Perl Numbers in JSON and YAML</title>
<style type="text/css">
body {
font-family: Verdana, Arial;
}
table.numbers {
border: 1px solid #bbb;
border-collapse: collapse;
---
block mapping:
a: 1
b: 2
block sequence:
- a
- b
- c