awohld has asked for the wisdom of the Perl Monks concerning the following question:

I'm parsing a CSV file and the third Column of the first row is always named 'Azimuth'.

The first time I look at $Azimuth while parsing, it's value will be "Azimuth".

Every other time I want to assign $Azimuth a value inside my "if($Azimuth != 'Azimuth')" statement.

But if $Azimuth is anything else besides "Azimuth", my HTML table isn't printing "Print This A LOT!!"

Why isn't $Azimuth updating with "Print This A LOT!!" inside my "if" statement or otherwise showing up in my HTML block?
my ($Y1, $X1, $Azimuth, $Y2, $X2, $Device) = $csv->fields; if ($Azimuth != 'Azimuth') {$Azimuth = "Print This A LOT!!";} print <<EOF; <tr> <td width="0" height="0">$Y1</td> <td width="0" height="0">$X1</td> <td width="0" height="0">$Azimuth</td> <td width="0" height="0">$Y2</td> <td width="0" height="0">$X2</td> <td width="0" height="0">$Device</td> </tr> EOF
Update: Changed "$Azimuth != 'Azimuth'" to "$Azimuth ne 'Azimuth'". I'm comparing text so the != numeric comparator won't work!

Replies are listed 'Best First'.
Re: Can't update variable - Local variable problem?
by merlyn (Sage) on Jul 29, 2005 at 04:00 UTC
      That fixed it! thanks!
Re: Can't update variable - Local variable problem?
by pg (Canon) on Jul 29, 2005 at 05:07 UTC

    Had you turned on warnings, you would have figured this out yourself.

    Argument "Azimuth" isn't numeric in numeric ne (!=) at www.pl line 6. Argument "a" isn't numeric in numeric ne (!=) at www.pl line 6. <tr> <td width="0" height="0">a</td> <td width="0" height="0">a</td> <td width="0" height="0">a</td> <td width="0" height="0">a</td> <td width="0" height="0">a</td> <td width="0" height="0">a</td> </tr>

    Turn on warning by using 'use warnings', or run with -w option.