use strict; use warnings; use Data::Dumper; my %h; while (<DATA>) { while (m/(\w+)\s?:\s?(\S*)/g){ $h{$1} = $2; } } print Dumper \%h; __DATA__ firstName : firstValue Name2: Value2 Name3:Value3 Name4:value4 Name5: Name6:
Note that use of \w and \S is guesswork on my part - it works for the example you gave, but it depends on your data format if that's the right choice.
Please only use <code>...</code> tags for code, put your question into normal paragraphs. See Writeup Formatting Tips.
In reply to Re: Selective String extraction & formatting
by moritz
in thread Selective String extraction & formatting
by harishnuti
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |