in reply to Re: N/A replacement not working
in thread N/A replacement not working

$i is an int. the print statement works fine as I've shown in the code snippet, and I have used strict. I'm not sure how your if-else is different from mine....nevertheless, I tried yours and it still returns N/A

Replies are listed 'Best First'.
Re^3: N/A replacement not working
by jethro (Monsignor) on Aug 10, 2011 at 15:47 UTC

    The difference is that his if-else actually does something to the data while your if-else is practically a no-op (i.e. it does nothing except testing the values)

    Are you sure that what you see as 'N/A' on the screen is not really "N/A\n" or ' N/A '? Also you test $h[$i], but print $h[1].

Re^3: N/A replacement not working
by duyet (Friar) on Aug 10, 2011 at 15:54 UTC

    The ($h[$i] eq 'N/A') ? 0 : $h[$i]; is working ok. The question is what do you want to do with this? As of now the result will be lost ... You need to save it into some var and act on it or print it.

    Which one of the prints returns the N/A? If it's the first one $h[0] = ($h[$i] eq 'N/A') ? 0 : $h[$i]; otherwise $h[1] = ($h[$i] eq 'N/A') ? 0 : $h[$i];

      thank you guys, I appreciate everyone's response and the clarification. Since I was not assigning it to the variable, it was giving the problem. it is fixed now :-)