Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

OK, Had to make some changes, but I got what I wanted. I am showing just the while loop that has been driving me nuts. Here are the changes:

while(<$IN>){ chomp; if (m/$start/) { $name = $1; next; } elsif (m/^record size:\s+(\d+)/) { $Hash{$name}{'record_size'} = $1; next; } elsif (m/^last record:\s+(\d+)/){ $Hash{$name}{'last_record'} = $1; next; } elsif (m/^data byte count:\s+(\d+)/) { $Hash{$name}{'data_byte_count'} = $1; next; } elsif (m/^\s+index name:\s+(\w.*)/) { push(@{ $Hash{$name}{'indexes'} }, $1); next; }else{ next; } } close $IN; foreach my $key (keys %Hash) { print $OUT "File: $key<BR>\n"; print $OUT "\tRecord Size: $Hash{$key}{'record_size'}<BR>\n" i +f defined $Hash{$key}{'record_size'}; print $OUT "\tLast Record: $Hash{$key}{'last_record'}<BR>\n" i +f defined $Hash{$key}{'last_record'}; print $OUT "\tData Byte Count: $Hash{$key}{'data_byte_count'}< +BR>\n" if defined $Hash{$key}{'data_byte_count'}; if (defined $Hash{$key}{'indexes'}){ my $str = join ', ', @{ $Hash{$key}{'indexes'} } ; print $OUT "Index Names: $str<BR><BR>\n"; }else{ print $OUT "<BR><BR>\n"; } } }

I ran the hash through Data::Dumper and was seeing all of the data, but was having an issue printing. I then noticed that some fields were missing in the data, so I went back and verified that they didn't exist in the actual files. Once I did that, I put in the defined checks and everything worked.

#

TStanley
--------
People sleep peaceably in their beds at night only because rough men stand ready to do violence on their behalf. -- George Orwell

In reply to Re: Pulling specific data from a large text file by TStanley
in thread Pulling specific data from a large text file by TStanley

Title:
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 How to display code and escape characters are good places to start.
Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (5)
As of 2024-03-28 23:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found