This sounds like it might at least be related to token parsing, in which case Parse::Token might work well for you. Otherwise, it's essentially a simple switch.
my @array; my $start_regex = qr/^\d{3}:/; # a line beginning with, e.g. 001: my $end_regex = qr/^:::$/; # a line with only ':::' while (<DATA>) { # replace with your FH if ( @array and $_ =~ $end_regex ) { # reached an 'end'. I assume you don't want to keep the end ' +tag' do_something_to(@array); undef @array; } elsif ( @array ) { # filling array push @array, $_; } elsif ( $_ =~ $start_regex and !eof DATA) { # begin filling up the array! push @array, $_; # I assume you want to keep the start 'tag' } else { # we haven't gotten a 'start', } } #_ while{} # deal with the possibility that we 'started' but didn't 'end' if (@array) { warn 'Start with out end at EOF!' }
In reply to Re: Simple Array Followup
by radiantmatrix
in thread Simple Array Followup
by jriggs420
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |