Skip to content

Instantly share code, notes, and snippets.

@snorkysnark
Created December 28, 2022 15:50
Show Gist options
  • Save snorkysnark/25369f89650aa166324b816ef28c2746 to your computer and use it in GitHub Desktop.
Save snorkysnark/25369f89650aa166324b816ef28c2746 to your computer and use it in GitHub Desktop.
foreach my $j (@institutions){
if($j eq '-'){
next;
}
$j=setnull($j);
#do_sql(...)
}
sub setnull{
my ($val)=@_;
#print "setnull orig $val\n";
$val=~s/\'+/\'/g;
$val=~s/\'/\'\'/g;
$val=~s/\A\-\Z//;
if($val eq ''){
$val="null";
}else{
$val="\'$val\'";
}
#print "setnull $val\n";
return $val;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment