Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

Namaste Monks!!

Here's a script that I've written which works like magic on a Linux or Unix machine. However when run on a windows machine a few errors and warning messages are thrown. Please let me know what the possible reasons for these problems cound be so the I'd be able to make the script error-free on windows.

#!usr/perl/bin -w use warnings; use strict; use diagnostics; use POSIX; ################################## #Global variable declarations ################################## my $file_431_inp = "kwd_431.txt"; my $file_471_out = "kwd_471.txt"; my $file_471_final_out = "MMS_KWD_4.71_CONVERTED.txt"; my $val; my $sbsb_id_431; my $sbsbid; my $i = 0; my $j = 0; my $sbsb_id_431_cnt = 0; my $sbsb_loop_cnt_471 = 0; my $sbsb_loop_cnt_471_act = 0; my $remainder = 0; my $eof = '@pRECTYPE="LEOF"'; my @file_431_arr = (); my @file_471_org_arr = (); my @file_471_upd_arr = (); my @file_471_fin_arr = (); my @file_sbsb_upd_arr = (); my @eof_arr = (); my @temp = (); ################################################################## +########### #No of Records / Subscriber(SBSB)loops in the Input Facets 4.31 KW +D file ################################################################## +########### open(INPFILE, "<$file_431_inp") || die ("Could not read the file") +; @file_431_arr = <INPFILE>; close(INPFILE); for ($i=0;$i<$#file_431_arr;$i++){ if ($file_431_arr[$i] =~/(^\@pRECTYPE="SBSB")(\S*)/){ if ($file_431_arr[$i] =~/(\@pSBSB_ID=")(\d{9})/){ $sbsb_id_431 = $2; $sbsb_id_431_cnt = $sbsb_id_431_cnt + 1; } } } print strftime ("%Y-%m-%d %H:%M:%S",localtime)." :: Number of Reco +rds / Subscriber(SBSB)loops in the Input Facets 4.31 KWD file is : $s +bsb_id_431_cnt\n\n"; ################################################################## +########## #Getting user Input for number of desired Duplicates in the output + 4.71 file ################################################################## +########## print strftime ("%Y-%m-%d %H:%M:%S",localtime)." :: Enter the numb +er of Records / Subscriber(SBSB)loops desired in the output KWD 4.71 +file.To obtain the most accurate results enter a value which is a mul +tiple of $sbsb_id_431_cnt\n\n"; $val = <STDIN>; $sbsb_loop_cnt_471 = int ($val / $sbsb_id_431_cnt); $remainder = ($val % $sbsb_id_431_cnt); $sbsb_loop_cnt_471_act = ($val - $remainder); print strftime ("%Y-%m-%d %H:%M:%S",localtime)." :: Creating outpu +t Facets 4.71 MMS KWD file with $sbsb_loop_cnt_471_act Records / Subs +criber(SBSB)loops\n\n"; ################################################################## +########## # Duplicating the contents of the Input Facets 4.31 KWD file ################################################################## +########## open(INFILE, "<$file_431_inp") || die ("Could not read the file"); my @file_431_org_arr = <INFILE>; close(INFILE); for ($j=0; $j<$sbsb_loop_cnt_471; $j++){ push (@file_471_org_arr,(@file_431_org_arr)); } open(OUTFILE, "+>$file_471_out") || die ("Could not open the file +in write mode"); print OUTFILE (@file_471_org_arr); close(OUTFILE); print strftime ("%Y-%m-%d %H:%M:%S",localtime)." :: $sbsb_loop_cnt +_471 duplicates of the input 4.31 KWD file successfully created with +a total record count of $sbsb_loop_cnt_471_act\n\n"; ################################################################## +########### # Implementing 4.71 changes, printing the WMDS_SEQ_NO segments to +new lines ################################################################## +########### open(UPDFILE, "<$file_471_out") || die ("Could not read the file") +; open(SBSBUPDFILE, "+>$file_471_final_out") || die ("Could not open + the file in append mode"); print strftime ("%Y-%m-%d %H:%M:%S",localtime)." :: 4.71 changes i +mplementation initiated\n\n"; foreach (<UPDFILE>){ if ($_ =~ /^(\@pRECTYPE=\"SBSB\")(.*)(\@pWMDS_SEQ_NO)(1)(= +\d{1})(.*)(\@pWMDS_SEQ_NO)(2)(=\d{1})(.*)(\@pWMDS_SEQ_NO)(3)(=\d{1})( +\,)(.*)$/){ print SBSBUPDFILE "$1$2$15\n"; push (@temp, $1); push (@temp, $2); push (@temp, $3); push (@temp, $4); push (@temp, $5); push (@temp, $6); push (@temp, $7); push (@temp, $8); push (@temp, $9); push (@temp, $10); push (@temp, $11); push (@temp, $12); push (@temp, $13); push (@temp, $14); push (@temp, $15); } elsif ($_ =~ /^\@pRECTYPE=\"MEME\"/){ print SBSBUPDFILE $_; if ($temp[4] ne '=0'){ print SBSBUPDFILE "\@pRECTYPE=\"MEWM\"\,\@pMEWM_UP +DATE_CD=\"AP\"\,$temp[2]$temp[4]\,\@pMEWM_EFF_DT=\"01/01/1900\"\,\@pM +EWM_TERM_DT=\"12/31/9999\"\,\@pMEWM_MCTR_TRSN=\" \"\n"; } if ($temp[8] ne '=0'){ print SBSBUPDFILE "\@pRECTYPE=\"MEWM\"\,\@pMEWM_UP +DATE_CD=\"AP\"\,$temp[6]$temp[8]\,\@pMEWM_EFF_DT=\"01/01/1900\"\,\@pM +EWM_TERM_DT=\"12/31/9999\"\,\@pMEWM_MCTR_TRSN=\" \"\n"; } if ($temp[12] ne '=0'){ print SBSBUPDFILE "\@pRECTYPE=\"MEWM\"\,\@pMEWM_UP +DATE_CD=\"AP\"\,$temp[10]$temp[12]\,\@pMEWM_EFF_DT=\"01/01/1900\"\,\@ +pMEWM_TERM_DT=\"12/31/9999\"\,\@pMEWM_MCTR_TRSN=\" \"\n"; } } else{ print SBSBUPDFILE $_; } } close(UPDFILE); close(SBSBUPDFILE); print strftime ("%Y-%m-%d %H:%M:%S",localtime)." :: 4.71 changes i +mplemented successfully\n\n"; ################################################################## +########### # Generating unique SBSB IDs ################################################################## +########### print strftime ("%Y-%m-%d %H:%M:%S",localtime)." :: Generation of +unique SBSB IDs initiated\n\n"; open(SBSBUPDFILE, "<$file_471_final_out") || die ("Could not open +the file in read mode"); my @sbsb_upd_471 = <SBSBUPDFILE>; close(SBSBUPDFILE); open(SBSBUPDFILE, "<$file_471_final_out") || die ("Could not open +the file in read mode"); while (<SBSBUPDFILE>){ if ($_ =~ /(\@pSBSB_ID=")(\d{9})/){ $sbsbid = $2; last; } } close(SBSBUPDFILE); my $flag = 0; for ($i = 0;$i<= $#sbsb_upd_471; $i++){ if ($sbsb_upd_471[$i] =~ /(\@pSBSB_ID=")(\d{9})/){ $sbsb_upd_471[$i] =~ s/\d{9}/$sbsbid/; $sbsbid++; } } open(SBSBUPDFILE, "+>$file_471_final_out") || die ("Could not open + the file in read mode"); foreach (@sbsb_upd_471){ print SBSBUPDFILE $_; } ################################################################## +################# #Removing the "LEOF" segments between the loops retaining it at th +e end of the file ################################################################## +################# open (SBSBUPDFILE, "<$file_471_final_out") || die ("Could not open + the file in read mode"); @eof_arr = <SBSBUPDFILE>; close (SBSBUPDFILE); for ($i = 0; $i <= $#eof_arr; $i++){ if ($eof_arr[$i] =~ /$eof/){ splice(@eof_arr,$i,1); } } push (@eof_arr,"$eof\n"); open (SBSBUPDFILE, ">$file_471_final_out") || die ("Could not open + the file in write mode"); foreach (@eof_arr){ print SBSBUPDFILE $_; } close (SBSBUPDFILE); unlink $file_471_out; print strftime ("%Y-%m-%d %H:%M:%S",localtime)." :: Generation of +unique SBSB IDs successful\n\n"; print strftime ("%Y-%m-%d %H:%M:%S",localtime)." :: Facets 4.71 MM +S KWD FILE - MMS_KWD_4.71_CONVERTED.txt with $sbsb_loop_cnt_471_act r +ecords created successfully\n"; close(SBSBUPDFILE); exit;

The errors that I find in the windows machine are mostly of this sort

Use of uninititialized value in string ne at scriptname.pl line 118, < +UPDFILE> line 266 <#1>
I've got no idea as to what's to be done about this!!! Please help me out. Thanks in advance!!


In reply to Code running perfectly fine in a Linux machine throwing errors whn run on windows by ajguitarmaniac

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (3)
As of 2024-04-18 01:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found