From a10c861f4c86d577b4c8441365106deee39aefb9 Mon Sep 17 00:00:00 2001 From: Yanick Champoux Date: Sun, 10 Dec 2017 13:53:52 -0500 Subject: [PATCH] part2 --- 09/2.pl | 24 ++++++++++++++++++++++++ 09/test | 1 + 2 files changed, 25 insertions(+) create mode 100644 09/2.pl create mode 100644 09/test diff --git a/09/2.pl b/09/2.pl new file mode 100644 index 0000000..4a0941b --- /dev/null +++ b/09/2.pl @@ -0,0 +1,24 @@ +use 5.20.0; + +my $stream = <>; +chomp $stream; + +my $garbage; +$stream = clean_stream($stream); + +say $garbage; + +use experimental qw/signatures /; + +sub clean_stream($s) { + + return $s unless $s =~ s/^(.*?))// ) { + warn $1; + $garbage += length $1; + last if $2 eq '>'; + } + + clean_stream($s); +} diff --git a/09/test b/09/test new file mode 100644 index 0000000..9a05711 --- /dev/null +++ b/09/test @@ -0,0 +1 @@ +{{},{},{},{}}