in reply to runnig part of script when variable changes

here is the code
#!/perl/bin open (In,"tascomod.log") or die ("an not open file at the moment"); open (Out, "tasmodtypfinrpt.txt") or die ("cannot open output file may +be you sho uld create one"); print "\n\n Session id Modulation \n\n"; my $firstlineFlag++; my $sessid; while (my $line = <IN>) { my @temp = split (/[=]/, $line); if ($temp[1] > 100) { print "Session id: $temp[1] "; } if ($firstLineFlag) { $sessid = $temp[1]; $firstLineFlag = ''; } if ($temp[1] ne $sessid) { if ($temp[1] == 20) { print " V34\n\n "; } $sessid = $temp[1]; } }

Replies are listed 'Best First'.
Re: Re: runnig part of script when variable changes
by rdfield (Priest) on Feb 22, 2002 at 10:33 UTC
    If you'd had 'use strict' at the top of the script you'd have spotted that '$firstlineFlag' is not the same as '$firstLineFlag'. Also the declaration of '$firstlineFlag' increments an uninitialised variable (which would have been caught with '-w'). Once it runs cleanly with 'strict' and 'warnings', you'll be in a better position to find out what the problem is with your algorithm. (I suspect that it will be OK when '$firstlineFlag' is changed to '$firstLineFlag').

    rdfield