Skip to content

Instantly share code, notes, and snippets.

@aero aero/parse.pl
Created Jan 21, 2016

Embed
What would you like to do?
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
You can’t perform that action at this time.