Jim Hill wrote:
> $Bill Luebkert wrote:
>
>>The eval already suggested by Chris should work
>
> It doesn't, unfortunately, unless I'm mishandling it in some way.
Try this one:
use strict;
use warnings;
my %ini;
my $inifile = 'test.ini';
make_ini ($inifile);
read_ini ($inifile);
print Data::Dumper->Dump([\%ini], [qw(\%ini)]);
# unwrap next three lines
my $line = '0000C000 00000000 18/02/2006 07:44:09 EXCEPTION (Scripting:
Language not installed) @ Script Execution [0068DFCD] Recursive call (3
times):';
# regex=^.*? (..:..:..) .*? \((.*?)\) .*
# match=$1 $2
$line =~ /$ini{test}{regex}/;
my $match;
eval qq{\$match = "$ini{test}{match}"};
print "match=$match\n";
exit;
#- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub make_ini {
my $inifile = shift;
open INI, ">$inifile" or die "create $inifile: $!";
print INI '[test]'."\n";
print INI 'regex=^.*? (..:..:..) .*? \((.*?)\) .*'."\n";
print INI 'match=$1 $2'."\n";
close INI or die "Can't close $inifile: $!";
}
#- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub read_ini {
my $inifile = shift;
my $section;
open INI, $inifile or die "open $inifile: $!";
while (<INI>) {
chomp;
next if /^\s*$/;
if (/^\[(.*)\]/) {
$section = $1;
next;
}
my ($field, $value) = split /=/, $_, 2;
$ini{$section}{$field} = $value;
}
close INI or die "Can't close $inifile: $!";
}
__END__
--
,-/- __ _ _ $Bill Luebkert Mailto:[EMAIL PROTECTED]
(_/ / ) // // DBE Collectibles Mailto:[EMAIL PROTECTED]
/ ) /--< o // // Castle of Medieval Myth & Magic http://www.todbe.com/
-/-' /___/_<_</_</_ http://dbecoll.tripod.com/ (My Perl/Lakers stuff)
_______________________________________________
Perl-Win32-Users mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs