Skip to content

Instantly share code, notes, and snippets.

@jberger
Created May 31, 2012 21:44
Show Gist options
  • Select an option

  • Save jberger/2846532 to your computer and use it in GitHub Desktop.

Select an option

Save jberger/2846532 to your computer and use it in GitHub Desktop.
Something More Elegant
#!/usr/bin/env perl
# in response to http://stackoverflow.com/a/10841473/468327
use strict;
use warnings;
my %data;
my $tag = 'Initial';
while (<DATA>) {
chomp;
if (/^(\w+):/) {
$tag = $1;
} else {
push @{$data{$tag}}, $_;
}
}
use Data::Dumper;
print Dumper \%data;
__DATA__
Summary:
xyz
Configuration:
abc
123
Tools:
pqr
456
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment