1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
#!/usr/bin/perl use strict; use warnings; use Data::Dumper; my $data = do{ local $/ = undef; <DATA> }; # Schlüssel my $k = [$data =~ /#~+(\w+)~+#/sg ]; # Werte my $v = [ $data =~ /~+#\n?(.*?)\n?#~+/sg ]; my %cfg = (); @cfg{@$k} = @$v; print Dumper \%cfg; # OK __DATA__ #~~~~~~~~~~~~~~~~foo~~~~~~~~~~~~~~~~~~~~~~~~# bar #~~~tempdir~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~# /home/framework/files/temp #~~~~cookiename~~~~~~~~~~~~~~~~~~~~~~~~~~~~~# FWNG #~~~~~mehrzeiliges~~~~~~~~~~~~~~~~~~~~~~~~~~# Name Vorname Am Stadtrand 123 99999 Henneberg #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
@cfg{ ( $data =~ /#~+(\w+)~+#/sg ) } = ( $data =~ /~+#\n?(.*?)\n?#~+/sg );
2015-01-07T14:10:25 payxmy %cfg = ($data =~ /#~+(\w+)~+#\n([^#]+)\n/sg);
HTH
Grüße
payx