Skip to content

Instantly share code, notes, and snippets.

@genehack
Created April 27, 2017 01:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save genehack/25984830fe146dac6c4b95b0f2964a24 to your computer and use it in GitHub Desktop.
Save genehack/25984830fe146dac6c4b95b0f2964a24 to your computer and use it in GitHub Desktop.
#! /usr/bin/env perl
use strict;
use warnings;
use feature 'say';
use DDP;
use YAML::XS qw/ DumpFile LoadFile /;
my $file = './aoa.yaml';
if ( -e $file ) {
my $data = LoadFile($file);
p $data;
}
else {
my $data = [ [ 1 .. 3 ], [ 4 .. 6 ] ];
DumpFile($file, $data);
say "Look at $file...";
}
irving:~/Desktop
☹ [ 0 ] % ./foo.pl 18:16:14
Look at ./aoa.yaml...
irving:~/Desktop
☺ % cat aoa.yaml 18:16:26
---
- - 1
- 2
- 3
- - 4
- 5
- 6
irving:~/Desktop
☺ % ./foo.pl 18:16:28
\ [
[0] [
[0] 1,
[1] 2,
[2] 3
],
[1] [
[0] 4,
[1] 5,
[2] 6
]
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment