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

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
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

In reply to Re: Re: Re: How can I deal with those big table data? by Trimbach
in thread How can I deal with those big table data? by Anonymous Monk

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or or How to display code and escape characters are good places to start.
Log In?

What's my password?
Create A New User
Domain Nodelet?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (5)
As of 2022-07-05 11:55 GMT
Find Nodes?
    Voting Booth?

    No recent polls found