Perl noob here – i have the following script
if(substr($pc, 3,1)!=" "){
$newpc = substr($pc, 0, 4) . " " . substr($pc, 4);
}
It’s designed to put a space in postcodes, for example NN141NJ becomes NN14 1NJ… however with postcodes such as NN102DE it doesn’t do anything, does Perl recognize " " and "0" as the same? How can I go about perl not ignoring strings with 0 as the fourth letter?
Use
neinstead of!=. The latter is for numeric comparisons, in which both are0in your case. Seeperldoc perlop