Having read your question several times, I can't make heads or tails from it. What is the schema of the database table? How do you store REC2 DATA3 DATA4 2 DATAX with 5 columns and RECZ 5 DATAX with 3 columns? Also, what do you mean by (NEW VALUE) ? Why is the first RECZ numbered with 5, but there's no number for the second RECZ?
If you just want to know how to persist a value across several iterations of a loop, the answer is simple: declare a variable before the loop.
#! /usr/bin/perl use warnings; use strict; my $grouping = q(); while (<DATA>) { my @columns = split; print "@columns $grouping\n"; if (@columns > 2) { $grouping = $columns[1] if q() eq $grouping; } else { $grouping = q(); } } __DATA__ REC1 DATAX DATA2 1 REC2 DATA3 DATA4 2 REC3 DATA5 DATA6 3 REC4 DATA7 DATA8 4 RECZ 5 REC1 DATAY DATA2 6 REC2 DATA3 DATA4 7 REC3 DATA5 DATA6 8 REC4 DATA7 DATA8 9 RECZ
($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,
In reply to Re: Sequential data read in MySQL/Perl
by choroba
in thread Sequential data read in MySQL/Perl
by justin423
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |