in reply to Re: taking sections out of a file and put it in an array
in thread taking sections out of a file and put it in an array

starts with $FILES and ends with $ :
my @arr; while (<FILE>) { push @arr, $1 if /^\$FILES(.*?)\$$/; }
(inserted '^' and '$' to mark start and end)

Replies are listed 'Best First'.
Re(3): Inserting sections of a file into an array
by cjf-II (Monk) on Dec 06, 2002 at 09:03 UTC

    Check juo's example, there will be more data after the $ so you'll need to leave of the second $ (as davorg did) or it won't match.

    open DATA, "junk.txt" or die $!; my @arr; while (<DATA>) { # add the extra $ and it won't print anything push @arr, $1 if /\$FILES(.*?)\$/; } close DATA; print $_, "\n" for @arr;

    Try it out.

    Update: I think I misinterpreted Chief of Chaos's post. If you want to ensure there's no data before the $FILE or after the $ then he is correct.

    Update: If you want each CSV as an individual array element, substitute the push line above with:

    push @arr, split(/, /, $1) if /\$FILES(.*?)\$/;

    Otherwise they'll all read into one element.