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
-
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.
|