in reply to Re: help...separating strings into arrays!
in thread help...separating strings into arrays!

Your script will store the contents of the file in memory twice.
This one will create the necessary arrays and fill them directly while reading the file.
#!/usr/bin/perl -w use strict; # create three empty array references my %arrays = map {$_, []} qw ( A B C ); my $ar_ref = undef; while (<DATA>) { if (/ABC header line (\w)/) { die "unrecognized header <$1>\n" unless exists $arrays{$1}; $ar_ref = $arrays{$1}; } else { die "no current array\n" unless $ar_ref; chomp; push @$ar_ref, $_; } } for (keys %arrays) { print "$_ => ( @{$arrays{$_}} )\n"; } __DATA__ ABC header line A A line 1 A line 2 A line 3 A line 4 ABC header line B B line 1 B line 2 B line 3 ABC header line C C line 1 C line 2 C line 3 C line 4
And this is the result:
A => ( A line 1 A line 2 A line 3 A line 4 ) B => ( B line 1 B line 2 B line 3 ) C => ( C line 1 C line 2 C line 3 C line 4 )
HTH

cchampion