Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: Re: Re: How can I deal with those big table data?

by Trimbach (Curate)
on May 20, 2002 at 02:30 UTC ( #167757=note: print w/replies, xml ) Need Help??


in reply to Re: Re: How can I deal with those big table data?
in thread How can I deal with those big table data?

There's still nothing in %MYHASH. Yes, you're declaring scope for %MYHASH and everything but just because %MYHASH is declared doesn't mean anything is in it. You have to assign some value or another into it in order for a while to work. Until there's something in your hash your while will never get executed and nothing will get printed.

You probably want something like this:

#!/usr/bin/perl -w use strict; my ($file_list, $file_data)=@ARGV; my %MYHASH; #create hash sub do_hash { my $filename=shift; open(FH, $filename) or die "Can't open $filename: $!\n"; while(<FH>){ my ($Name, $Data)=split,2; $MYHASH{$Name} = $Data; } close FH; } do_hash('file_data'); foreach my $key (keys %MYHASH) { print "$key => $MYHASH{$key}\n"; } exit;
Note the fact that %MYHASH is assigned a whole bunch 'o data from the file, and after do_hash is completed (and %MYHASH has stuff in it) THEN all the data is printed out. And BTW, it should've probably been split, 2 not split, 1.

Gary Blackburn
Trained Killer

Replies are listed 'Best First'.
Re: Re: Re: Re: How can I deal with those big table data?
by Anonymous Monk on May 21, 2002 at 01:15 UTC
    Thanks, You are right, I make it today.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (4)
As of 2021-10-24 18:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My first memorable Perl project was:







    Results (89 votes). Check out past polls.

    Notices?