Perl version: /usr/bin/perl -> /usr/opt/perl5/bin/perl5.8.8 Perl maxdata=0x80000000 OS: AIX 6100-09-04-1441 All user ulimits =unlimited Here is the script: #!/bin/perl # File: get-count.pl # # Perl script to locate the trailer record of a Fiserv data file and r +eturn # the following information # # Usage: # perl get-count.pl INPUT_FILE # # Number of records per the trailer # Number of records based on the file size and record size # Record size. sub to_ascii { my($s) = @_; $s =~ tr/\x40\x5a\x7f\x7b\x5b\x6c\x50\x7d\x4d\x5d\x5c\x4e\x6b\ +x60\x4b\x61\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\x7a\x5e\x4c\x7e\x +6e\x6f\x7c\xc1 \xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\x +e2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xad\xe0\xbd\x5f\x6d\x79\x81\x82\x83\x8 +4\x85\x86\x87\ x88\x89\x91\x92\x93\x94\x95\x96\x97\x98\x99\xa2\xa3\xa4\xa5\xa6\xa7\xa +8\xa9\xc0\x6a\xd0\xa1/\x20\x21\x22\x23\x24\x25\x26\x27\x28\x29\x2a\x2 +b\x2c\x2d\x2e\ x2f\x30\x31\x32\x33\x34\x35\x36\x37\x38\x39\x3a\x3b\x3c\x3d\x3e\x3f\x4 +0\x41\x42\x43\x44\x45\x46\x47\x48\x49\x4a\x4b\x4c\x4d\x4e\x4f\x50\x51 +\x52\x53\x54\x 55\x56\x57\x58\x59\x5a\x5b\x5c\x5d\x5e\x5f\x60\x61\x62\x63\x64\x65\x66 +\x67\x68\x69\x6a\x6b\x6c\x6d\x6e\x6f\x70\x71\x72\x73\x74\x75\x76\x77\ +x78\x79\x7a\x7 b\x7c\x7d\x7e/; return($s); } sub file_info { my($file) = @_; open(FP2, "<$file") || die return(-1,-1, -1); binmode(FP2); my($file_size) = -s $file; my($buf_size) = 6000; if($buf_size > $file_size) { $buf_size = $file_size; } my($s) = ''; seek(FP2, -$file_size, 2); read(FP2, $s, $file_size); my($s2) = &to_ascii($s); if($s2 =~ /999 (\d\d\d\d\d\d\d\d\d)( +$)/) { my($rec_size) = 4 + length($1) + length($2); my($rec_count) = $1 + 0; my($rec_count_calc) = ($file_size / ($rec_size)) - 1; return($rec_count, $rec_size, $rec_count_calc); } else { return(-1, -1, -1); } close(FP); } foreach $file (@ARGV) { my($rec_count, $rec_size, $rec_count_calc) = &file_info($file); print "File: $file\nRecord Count: $rec_count\nComputed Record Coun +t: $rec_count_calc\nRecord Size:$rec_size\n"; } Here is more information about the perl compiled: perl -V Summary of my perl5 (revision 5 version 8 subversion 8) Built under aix Compiled at May 19 2013 14:46:07 @INC: /usr/opt/perl5/lib/5.8.8/aix-thread-multi /usr/opt/perl5/lib/5.8.8 /usr/opt/perl5/lib/site_perl/5.8.8/aix-thread-multi /usr/opt/perl5/lib/site_perl/5.8.8 /usr/opt/perl5/lib/site_perl
In reply to Perl Out of memory error by vdel2393
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |