in reply to How to input variable value from a file?

Assuming the data file is delimited with spaces like so:
servername-001 imm-servername-001.companyname.com servername-002 imm-servername-002.companyname.com
Then the following would work:
open my $fh, $serverfile or die "Can't open $serverfile: $!"; my @services = map {chomp; [split]} <$fh>; close $fh;

Replies are listed 'Best First'.
Re^2: How to input variable value from a file?
by perl_newbie99 (Initiate) on Jun 09, 2011 at 20:19 UTC
    Hi Wind, Thanks.. it worked (except for a minor fix). Thanks again! :)
    #open my $fh, $serverfile or die "Can't open $serverfile: $!"; open my $fh, "serverfile" or die "Can't open $serverfile: $!"; my @services = map {chomp; [split]} <$fh>; close $fh;

      You just need to initialize the variable.

      Don't forget use strict; and use warnings at the top of every script.

      use strict; use warnings; my $serverfile = 'foo.bar';