Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Perl Misc (http://www.velocityreviews.com/forums/f67-perl-misc.html)
-   -   <tns:Header> error at read line (http://www.velocityreviews.com/forums/t904461-tns-header-error-at-read-line.html)

gil 09-04-2007 02:37 PM

<tns:Header> error at read line
 
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-
}
}
}


usenet@DavidFilmer.com 09-04-2007 05:22 PM

Re: <tns:Header> error at read line
 
On Sep 4, 7:37 am, gil <gil.kov...@gmail.com> wrote:
> 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
<DATA> block.

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



--
The best way to get a good answer is to ask a good question.
David Filmer (http://DavidFilmer.com)




All times are GMT. The time now is 05:18 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.