Given the posted sample data, and the logic for assigning values to "$acctn" and "$curr_acctn", that "if" condition is only true for the first line of input (and on that iteration, the only thing you do inside the "if" block is $first_time = "no";if($acctn != $curr_acctn) { ...
The debugger shows this if you set a break point at line #29, which is the first line inside the block of that is supposed to do all the real work:
The program runs to "completion" without ever reaching that line, because the $acctn is always equal to $curr_acctn (except on the first iteration, where line 29 doesn't come into play).foreach my $account (@account_list) { ...
Since nothing inside that block is ever reached, nothing gets printed to the output file. If you're seeing some different problem, you must be using code and/or data that are different from what you've posted here.
It took me a while to figure out how your sample input relates to the desired output. Something like the following might suffice -- I'm not sure I really understand all the details of the intended application, but this creates the desired output for the given input:
That obviously pays no attention to lots of policy details implicit in the OP, but perhaps it provides a template that you can build on.#!/usr/bin/perl use strict; ( @ARGV == 2 and -f $ARGV[0] ) or die "Usage: $0 input.file output.file\n"; my $outname = pop @ARGV; open( OUT, ">", $outname ) or die "$outname; $!\n"; my $prev_rec; while (<>) { s/^42/CH /; s/\s+$/ LAB\n/; if ( ! $prev_rec ) { $prev_rec = $_; next; } if (( /4039140\s/ and $prev_rec =~ /4039139\s/ ) or ( /4039139\s/ and $prev_rec =~ /4039140\s/ )) { s/40391(?:39|40)(?=\s)/4039142/; print OUT; $prev_rec = ''; } else { print OUT $prev_rec; $prev_rec = $_; } } print OUT $prev_rec if ( $prev_rec );
In reply to Re: hash help
by graff
in thread hash help
by cesear
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |