<tns:Header> error at read line

Discussion in 'Perl Misc' started by gil, Sep 4, 2007.

  1. gil

    gil Guest

    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-
    }
    }
    }
     
    gil, Sep 4, 2007
    #1
    1. Advertising

  2. gil

    Guest

    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: <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)
     
    , Sep 4, 2007
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    0
    Views:
    1,005
  2. Replies:
    0
    Views:
    5,245
  3. Woolli
    Replies:
    1
    Views:
    798
    Alexey Smirnov
    Mar 21, 2007
  4. CJM
    Replies:
    7
    Views:
    592
  5. Alexey Verkhovsky
    Replies:
    0
    Views:
    121
    Alexey Verkhovsky
    Sep 24, 2004
Loading...

Share This Page