#!/usr/bin/perl -w

foreach $file (@ARGV) {
  $backup = $file.".bak";
  system("cp $file $backup");
  open(IN, "$backup")||die("Cannot open input $backup");
  open(OUT, ">$file")||die("Cannot open output $file");
  while (<IN>) {
    s/(?<!hpic_)is_dnull/hpic_is_dnull/g;
    s/(?<!hpic_)is_fnull/hpic_is_fnull/g;
    s/(?<!hpic_)is_inull/hpic_is_inull/g;
    s/(?<!hpic_)nsidecheck/hpic_nsidecheck/g;
    s/(?<!hpic_)nside2npix/hpic_nside2npix/g;
    s/(?<!hpic_)npix2nside/hpic_npix2nside/g;
    s/(?<!hpic_)nest2ring/hpic_nest2ring/g;
    s/(?<!hpic_)ring2nest/hpic_ring2nest/g;
    s/(?<!hpic_)pix2ang_ring/hpic_pix2ang_ring/g;
    s/(?<!hpic_)pix2ang_nest/hpic_pix2ang_nest/g;
    s/(?<!hpic_)ang2pix_ring/hpic_ang2pix_ring/g;
    s/(?<!hpic_)ang2pix_nest/hpic_ang2pix_nest/g;
    s/(?<!hpic_)vec2ang/hpic_vec2ang/g;
    s/(?<!hpic_)ang2vec/hpic_ang2vec/g;
    s/(?<!hpic_)pix2vec_ring/hpic_pix2vec_ring/g;
    s/(?<!hpic_)pix2vec_nest/hpic_pix2vec_nest/g;
    s/(?<!hpic_)vec2pix_ring/hpic_vec2pix_ring/g;
    s/(?<!hpic_)vec2pix_nest/hpic_vec2pix_nest/g;
    s/(?<!hpic_)degrade_ring/hpic_degrade_ring/g;
    s/(?<!hpic_)degrade_nest/hpic_degrade_nest/g;
    s/(?<!hpic_)proj_car/hpic_proj_car/g;
    s/(?<!hpic_)proj_sin/hpic_proj_sin/g;
    s/(?<!hpic_)proj_rev_car/hpic_proj_rev_car/g;
    s/(?<!hpic_)proj_rev_sin/hpic_proj_rev_sin/g;
    print OUT $_;
  }
  close(IN);
  close(OUT);
}




