On Jan 2, Paul Kraus said:
>I want to read through a file and the read through it again. However the
>only way it seems to work for me is if I open the file, Read the file,
WHY do you want to read the file twice? Is there some way you can do two
things at once?
>foreach (<PEL>){
> chomp;
> @temp=split /,/,$_;
> $_=~s/ //g foreach (@temp);
> $dup{$temp[1]}++;
>}
>
>foreach (<PEL>){
> chomp;
> @temp=split /,/,$_;
> print "$_\n" foreach (@temp);
> $_=~s/ //g foreach (@temp);
> $vend{$temp[1]}=$temp[0];
>}
Why are you using a foreach loop, rather than a while loop? And you CAN
do these two things at the same time.
while (<PEL>) {
chomp;
s/ +//g; # remove spaces
my ($value, $field) = split /,/;
$dup{$field}++;
$vend{$field} = $value;
}
--
Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/
RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/
<stu> what does y/// stand for? <tenderpuss> why, yansliterate of course.
[ I'm looking for programming work. If you like my work, let me know. ]
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]