in reply to Selective String extraction & formatting

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.

Replies are listed 'Best First'.
Re^2: Selective String extraction & formatting
by harishnuti (Beadle) on Jul 03, 2008 at 09:17 UTC

    First of all i apologize for formatting, it was a typo on putting code tag, and secondly thx for the tip.

      The apology may be taken better if you fix the tags.
        Done Thx