I have a Unix text file containing records in the following format:
r1f1|r1f2|r1f3!r2f1|r2f2| ... etc.
I can easily break up the individual 'lines' in this record by using split on the '!' character (actually a chr(13)). This puts each line into an array entry in @segs.
What I now need to do is pull out an individual field from an individual line and put it into a variable.
What I've coded so far (am leaving a lot of extra 'stuff' out here):
What I need to do is assign the value of, say, parts(3) to the variable ptname - but everything I've tried fails.
Thoughts/comments appreciated.
Tnx.
Tom
"My mind is like a steel whatchamacallit ...
r1f1|r1f2|r1f3!r2f1|r2f2| ... etc.
I can easily break up the individual 'lines' in this record by using split on the '!' character (actually a chr(13)). This puts each line into an array entry in @segs.
What I now need to do is pull out an individual field from an individual line and put it into a variable.
What I've coded so far (am leaving a lot of extra 'stuff' out here):
Code:
my @segs = ();
my @parts = ();
$ptname = "";
if (open(MYFILE, "xxx"))
{
$line = <MYFILE>;
while ($line ne "")
{
@segs = &breakup($line);
foreach $seg (@segs)
{
@parts = &breakupsegment($seg);
...
}
...
$line = <MYFILE>;
}
sub breakup
{
$CR = chr(13);
@segs = split(/$CR/, $line);
}
sub breakupsegment
{
@parts = split(/\|/, $seg);
}
What I need to do is assign the value of, say, parts(3) to the variable ptname - but everything I've tried fails.
Thoughts/comments appreciated.
Tnx.
Tom
"My mind is like a steel whatchamacallit ...