<tns:Header> error at read line
am 04.09.2007 16:37:09 von gil
I'am working on solaris 10, reding from a log file and get this
strange looking error:
when trying to print some of the lines.
the code:
while ($line = ) {
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-
}
}
}
Re: <tns:Header> error at read line
am 04.09.2007 19:22:40 von usenet
On Sep 4, 7:37 am, gil wrote:
> I'am working on solaris 10, reding from a log file and get this
> strange looking error:
That's not a Perl message. I think it's one of the values in your
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 = ) {
> if ($i !~ /log$/) { # $i is the file name
Why are you looping over 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)