http://www.perlmonks.org?node_id=754929

koti688 has asked for the wisdom of the Perl Monks concerning the following question:

I have a following script like
open(TEST,"<$sigDataFile") || die("This file will not open!"); my $sigData = <TEST>; my @records = (); @records = <TEST>; close(TEST); my @keys; my @values; foreach my $rec(@records) { my ($key,$value)=split(/\=/,$rec); push @keys,$key; print @keys; push @values,$value; print @ values }
And my sigData.txt contains 4 records lets say like below.

1=2
2=3
3=4
4=5


when i executed the script , the values in the very first line are missing while printing key and values

Replies are listed 'Best First'.
Re: help regarding reading a file
by Gangabass (Vicar) on Apr 02, 2009 at 12:32 UTC

    Of course! You are reading the very first line on this line:

    my $sigData = <TEST>;

    So you need to remove it.

      Hmm , my mistake , i was not looking properly at that.Thanks it worked.
Re: help regarding reading a file
by lakshmananindia (Chaplain) on Apr 02, 2009 at 12:37 UTC

    You are reading the first line by

    my $sigData = <TEST>;

    You also didn't use the $sigData anywhere. What is is the purpose of $sigData? If you don't need then remove it, else specify the use of $sigData

    --Lakshmanan G.

    The great pleasure in my life is doing what people say you cannot do.


    A reply falls below the community's threshold of quality. You may see it by logging in.
Re: help regarding reading a file
by Gangabass (Vicar) on Apr 02, 2009 at 13:46 UTC