Patrick Hall wrote:
>
> Hi,
>
> I've written a script with a run-of-the-mill open in
> it, like this:
>
> $file = "myfile.txt";
> open(FH, $file);
You should always check the return from open.
open FH, $file or die "Cannot open $file: $!";
> @lines = <FH>;
> close(FH);
>
> Now I'd like to modify it to open several files,
> namely, ($myfile1, $myfile2, $myfile3) and store those
> into @lines.
>
> I've tried using glob, but I can only get the file
> _names_ into the array, not contents. I guess I could
> just write three separate opens [i.e., open(FH1,
> "file1.txt") and so on] and then put each into an
> array, then push those onto @lines, but it seems like
> there should be an easier way.
my @files = ($myfile1, $myfile2, $myfile3);
my @lines = do { local @ARGV = @files; <> };
John
--
use Perl;
program
fulfillment
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]