Created
May 31, 2012 21:44
-
-
Save jberger/2846532 to your computer and use it in GitHub Desktop.
Something More Elegant
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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