<tns:Header> error at read line

G

gil

I'am working on solaris 10, reding from a log file and get this
strange looking error: <tns:Header>
when trying to print some of the lines.

the code:
while ($line = <DATA>) {
if ($i !~ /log$/) { #
$i is the file name
if ($time_flag == 0 )
{
$dif = "_";
if (($line
=~ /^\[\d\d/) && ($line!~ /^<\?xml/)) {$dif = (get_dif($line));}
if ((defined
($dif) ) && ($dif <= (60 * $min_num ))) {

$time_flag = 1;
if
($type eq "TYPE1") {print $i . " " . $line . "\n";} # -here-
}
}
}
 
U

usenet

I'am working on solaris 10, reding from a log file and get this
strange looking error: <tns:Header>

That's not a Perl message. I think it's one of the values in your
the code:

This isn't code, it's a bizarre code fragment (you have not closed
your while loop or your first if block). The logic of it escapes me in
many regards.
while ($line = <DATA>) {
if ($i !~ /log$/) { # $i is the file name

Why are you looping over <DATA> and checking $i each time? $i is not
set within your while block, so it is either always true or always
false here.
if ($time_flag == 0 ) {

For the first iteration of your while block this will always evaluate
as true. Is this what you intended?
$dif = "_";
if (($line =~ /^\[\d\d/) && ($line!~ /^<\?xml/)) {

So you are checking this condition: If the line begins with bracket
and two digits, and the line does NOT begin with an xml pragma...
huh? If it begins with bracket-digit-digit it cannot possibly begin
with an xml pragma. What's with the second condition?
$dif = (get_dif($line));
}
if ((defined ($dif) ) && ($dif <= (60 * $min_num ))) {

Can get_dif return undef? (if not then it's silly to check for defined-
ness.) $dif is given a value ('_') before the conditional. If the
condition is not true (ie, if $line does not match the regexp) then
get_dif is never called, so when you get to this conditional then $dif
eq '_' which will always evaluate as <= any non-negative numeric value
(including zero). I doubt this is your intent.
$time_flag = 1;
if ($type eq "TYPE1") {
print $i . " " . $line . "\n";} # -here-

Why all the concats? Just print "$i $line\n";

Are you sure the output you are seeing is actually coming from this
print statement and not some other?

Where are the final two closing curlys?

I strongly recommend that you use strict and properly scope your
variables. Doing so will probably reveal your problem.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,733
Messages
2,569,440
Members
44,830
Latest member
ZADIva7383

Latest Threads

Top