Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

help regarding reading a file

by koti688 (Sexton)
on Apr 02, 2009 at 12:25 UTC ( #754929=perlquestion: print w/replies, xml ) Need Help??

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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://754929]
Approved by rovf
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (3)
As of 2022-08-17 22:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?