#!/usr/bin/perl
#
# Author: Prabakar, School of Computing and Information Sciences, FIU
#         prabakar@cis.fiu.edu
#         7/6/2014
#
# Do NOT edit this file (on Windows)
#
# If any of the CGI/Perl file is edited using Windows text editors
# there will be a CR (carriage return character) at the end
# of each line on the script file. This causes problem in executing
# the script file on any Unix/Linux system.
# This scrip file automatically examines each CGI/Perl file
# present in the current directory, removes the extra CR character
# (if present) and rewrites the modified script on the same file.
#
# If any CGI/Perl file is updated on Windows platform,
#  execute this perl script on Unix.
#

# check for correct number of arguments
if ($#ARGV >= 0) { # in Perl, argcnt is zero for one argument
    die "Usage: $0 (with no argument) \n";
}

foreach $f (`/bin/ls *.cgi *.pl`) {
  $f =~ s/\s+$//; # strip trailing whitespace
  print " Processing $f\n";
  @line = `cat $f`;
  open(newF, ">$f") || die "cannot open output file $f - $!";
  for ($idx = 0; $idx <= $#line; $idx++) {
    $line[$idx] =~ s/\n$//; # strip LF at the end of lin
    $line[$idx] =~ s/\r$//; # strip CR at the end of lin
    print newF "$line[$idx]\n";
  }
  close(newF);
}
exit(0);
