in reply to Re: Modular Code
in thread Modular Code
You are treating @contents as a global.
I would do this like:
use strict; use IO::File; my @contents = open_file('myfile.txt'); sub open_file { my $fh = IO::File->new($_[0], 'r') or die "Could not open file $_[0]:$!"; # slurp mode only if the don't want an array local $/ unless wantarray; return <$fh>; }
|
|---|