Beri-Veera-ext, Reddy (n.a.) wrote:
> Hi all,
> I wrote a sample program with your guide lines but the associative
> array has double entries. Please the attachment for my program and
> test.txt file. Please tell me what I did the wrong.
If you post a script without the use strict and use warnings, I'll
pass on replying:
#!/usr/bin/perl
use strict;
use warnings;
my $file = 'C:/temp/export/CONVERSION/test.txt';
$file = 'data/test.txt'; # modified for me
my %info = ();
open TEST, $file or die "open $file: $! ($^E)";
my $found = 0;
while (<TEST>) {
chomp;
if (/PLMEJob Master/) {
$found = 1;
next;
}
if ($found) {
last if /^\s*$/;
my @a = split /=/;
$info{$a[0]} = $a[1] || ''; # or use something like 'No value'
}
}
close TEST;
print "$_ => $info{$_}\n" foreach keys %info;
__END__
_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs