in reply to a few basic questions
2) is a bit harder. I'm sure there are many elegant solutions. Some probably got posted while I was looking into it. My first try, if the files aren't too big, would be to slurp them into arrays and then fold them together.
the t1 file looks like the END block but with 2 instead of 1 I getuse strict; use warnings; open (T1, "t1") or die; my @file1 = <T1>; my @file2 = <DATA>; my @file; while (@file1 and @file2) { push @file, (shift @file1, shift @file2); } push @file, @file1 or @file2; #catch any leftover while (my $line = shift @file) { #do 'things' with it print $line; } __END__ file1 file1 file1 file1
Not sure what the warnings for, I guess because one of the array's is empty maybe? I'll bet if you put that into an if/else it wouldn't complain.Useless use of private array in void context at junk line 13. file2 file1 file2 file1 file2 file1 file2 file1 file2 file3, kidding... file2
There's probably a more elegant solution, but this is what comes to mind.
3) Did you try it? I just ran the code you posted (cleaned up with ';' :-) and got this
and gotuse strict; use warnings; $/ = "****"; my @array; while (<DATA>) { chomp; push @array, $_; $/= "####"; } print "@array"; __END__ stuff****more stuff####less
$ perl junk stuff more stuff less
Hope this helps
Ira
"So... What do all these little arrows mean?"
~unknown
|
|---|