Robert Canary wrote:
>
> Hello GreyBear,
>
> The problem is the the items(item1,item2,item3) are coming from a log file of
> another app. So I must first must split them from the line that I am cutting
> out of the logfile. The log file line states them as item1='value1',
> tem2='value2' all on one line there is seven item=value pairs on one line of
> extracted text. I can capture the text of the log file. But I can't get it
> into an array. I was trying the item/value scenario as though you would read
> it from a file. But the only way I can get a loop to roll over is if it is an
> array.
OH. I didn't know there would be multiple a=b on the same line. try
this:
--------------------------
open(IN,"foo") or die("$0: Could not open foo for read: $1");
#Read file, load array
while(<IN>)
{
chomp();
$Line=$_;
while($Line =~ s/^(\w+)=(\w+)\,{0,1}\s*//)
{
if($1 ne '')
{
$Line{$1}=$2;
}
}
}
foreach $Key (keys(%Line))
{
print("[$Key]=[$Line{$Key}]\n");
}
--------------------------
[D:/Devel] cat foo
fname=David, mname=Scott, lname=Kramer, job=Programmer
afname=aDavid, mname=aScott, alname=aKramer, ajob=aProgrammer
[D:/Devel] perl iniread2.pl
[afname]=[aDavid]
[job]=[Programmer]
[ajob]=[aProgrammer]
[lname]=[Kramer]
[alname]=[aKramer]
[mname]=[aScott]
[fname]=[David]
--
-------------------------------------------------------------------
DDDD David Kramer [EMAIL PROTECTED]
DK KD http://kramer.ne.mediaone.net
DKK D
DK KD HYDROGEN: A colorless, odorless gas which,
DDDD given enough time, turns into people.
--
To unsubscribe: mail [EMAIL PROTECTED] with "unsubscribe"
as the Subject.