venky144 has asked for the wisdom of the Perl Monks concerning the following question:
Hello Monks, For the last few months, we have been facing issues with the Perl script given below.
We have two different versions of Perl over here. Below are the details of the Active Perl versions: Newer Version: (Downloaded file has an error) Active Perl 5.10.0.1005 PPM Version 4.05 Older Version: (Downloaded file which was correct) Active Perl 5.10.0.1004 PPM Version 4.03 The upstream job that works on the files was working fine with the file downloaded by older version (Active Perl 5.10.0.1004), but fails when uses the file downloaded by newer version (Active Perl 5.10.0.1005) After our troubleshooting, we found out that the file downloaded by newer version come with empty rows between data, since the .csv files came with spaces (empty rows), it is not being processed and fails. It is because perl is generating the output file in unix format which has a control ^M character at the end of each line. so to convert the unix format file to linux format file, i need to use a command call "unix2dos" which is not available in windows. I can download the utility and put in system32 but my admin doesnt allow it, he wants me to do everything in Perl. There are many of scripts that fail and the issue is same. This is a Production Issue we had been facing from past 8-9 months. This error came out while we were migrating and testing all the scripts from old server to a new one due to Company’s Hardware Recycle Policy. We didn’t have the Active Perl 5.10.0.1004, so have installed Active Perl 5.10.0.1005 in the new one. Once this issue is solved, we would migrate all the scripts left over in the old one to current production. Can you please help out with this issue I am facing?use WWW::Mechanize; use Storable; #--------------------------------------------------------------------- +--------- # Define Variables for this process #--------------------------------------------------------------------- +--------- # File Down load path is used as a varible: $DownloadFilePath=<Path na +me> $DownloadFilePath="D:\\LIPAPSM\\DSSourcefiles\\"; #===================================================================== +========= # START OF PROGRAM #===================================================================== +========= $one_day = 60*60*24 ; my($day, $month, $year) = (localtime time+$one_day)[3,4,5]; $month = sprintf '%02d', $month+1; $day = sprintf '%02d', $day; $Datetotal=($year+1900).$month.$day; $filedate=join "", $Datetotal."damlbmp_zone.csv"; $url = join "",'http://mis.nyiso.com/public/csv/damlbmp/'.$filedat +e; $m = WWW::Mechanize->new(autocheck => 1); $m->get($url); $filename=join "",$DownloadFilePath.$filedate; $m->save_content($filename);
|
|---|