in reply to Getting variables from file
If you are looking to get the contents of the file into a simple string (a 'scalar') variable, you have a number of option.
Roll your own.
You can read a file into an array in one go, which terminates on End-Of_file:
my $file = 'foo.bar'; open(FH, $file); # as you already have my @temp = <FH>; # pull all lines into a list close FH; # because we are good people my ($name1, $name2, $address, $phone) = split("\t", @temp[0]);
Option 2: File::Slurp
For most of my code, I use File::Slurp these days:
use File::Slurp; my $file = 'foo.bar'; my $temp = read_file($file); my ($name1, $name2, $address, $phone) = split("\t", $temp);
(and you do realise that your split should really be using '/' for the regexp, not quotes? It's working because perl will accept any non-alphanumeric as a regexp delimiter is certain cases. Clever Perl :) )
|
|---|