in reply to multi-line regex match quest

It ain't pretty, but using the sexeger (reverse regex) technique, which can no doubt be implemented better, this works.

It requires you start with your lines in an unchomped array rather than a single line though.

my @g=<DATA>; my $id = 'key3'; my $g = join'',reverse @g; if (my ($ret) = $g =~ m/^$id=.*?\n(.*?)\n\n/s) { $ret = join$/,reverse split$/,$ret; print $ret; } else { print 'Failed!'.$/; } __DATA__ ## START # comment 1 # 2 # 3 # 4 key1=val1 # info a # b # c # d # e key2=val2 # comment ! # @ # # key3=val3

Cor! Like yer ring! ... HALO dammit! ... 'Ave it yer way! Hal-lo, Mister la-de-da. ... Like yer ring!

Replies are listed 'Best First'.
Re: Re: multi-line regex match quest
by nagilum (Initiate) on Sep 30, 2002 at 15:21 UTC
    Did you ever consider using Config::IniFiles ?
    Could save you a lot of time..