Skip to content

Instantly share code, notes, and snippets.

@briandfoy
Created October 11, 2010 20:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save briandfoy/621167 to your computer and use it in GitHub Desktop.
Save briandfoy/621167 to your computer and use it in GitHub Desktop.
use 5.010;
use Data::Dumper;
my %hash;
while( my $line = <DATA> ) {
chomp $line;
given ( $line ) {
chomp $line;
when( /<start>/ ) {
my $string;
until( (my $l = <DATA>) =~ /<end>/ ) { $string .= $l }
$hash{multiline} = $string;
}
when( /(.*?):(.*)/ ) {
$hash{$1} = $2;
}
}
}
print Dumper( \%hash );
__DATA__
Field 1 : data 1
Field 2 : data 2
Field 3 : data 3
Field 4 :
<start>
...
..
<end>
field 5 : data 5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment