PDA

View Full Version : help with a pipe seperated file.


crca
12-04-2002, 08:10 PM
i need help to seperate the varible "@pipe".

it comtains:

100123|21
201572|64
454684|01


how can i seperate this so that each piece of text is seperated.

I.E.:
@pipe{1} = 100123
@pipe{2} = 21

etc etc

Thanks in advaced!

Tim

Grizz2
12-04-2002, 10:09 PM
You could do something like this.

open(FILE,"somefile.txt") || print "$!";
while(<FILE>)
{
$line = $_;
chomp($line);
($var1,$var2) = split(/\|/, $line);
#if you want these in 2 arrays like your example
push(@array1, $var1);
push(@array2, $var2);
#or if youre just searching for a record,
# do your comparison instead
}
close(FILE);

Grizz

crca
12-05-2002, 08:42 PM
that is really big help!!

Thanks again!