Skip to content

Instantly share code, notes, and snippets.

@aero
Created January 21, 2016 02:54
Show Gist options
  • Save aero/1945abb4acecd62ba50e to your computer and use it in GitHub Desktop.
Save aero/1945abb4acecd62ba50e to your computer and use it in GitHub Desktop.
text section parsing
#!/usr/bin/env perl
use strict;
use warnings;
my $s = do { local $/; <DATA> };
my %section = $s =~ m/
^{{{(.*?)}}}-+$
\n(.*?)
(?=\n{{{.*?}}}-+$|\Z)
/xmsg;
use Data::Dump;
dd(\%section);
__DATA__
{{{hostname}}}-----
myhost
{{{hostname -f}}}-----
myhost.domain.com
{{{dmidecode}}}-----
dadfadf
adfafa
adfadf
{{{mycmd -h}}}-----
dfada
dfas
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment