A
Adimax
Very new to perl, but not programming in general. What I'm trying to
do is get a dynamically changing file in list format - something like:
apple
orange
pear
and get the code to pull that into an if statement. I've gotten as far
as being able to print the list:
% open (FILE, "/var/www/test");
% my @custom = <FILE>;
% chomp @custom;
% # print "@custom"; # this prints out 'apple orange pear'
% close FILE;
And my if statement works if I define it specifically:
% if ($server eq "apple" or $server eq "orange" or $server eq "pear")
{
display some text
% }
% } # endif $server
However, if I try to use something like:
% # if ($server eq @custom) {
display some text
% }
% } # endif $server
every $server is included in the 'display some text'. I know I'm off
a bit here, but any help or references to examples would be greatly
appreciated.
Benjamin
do is get a dynamically changing file in list format - something like:
apple
orange
pear
and get the code to pull that into an if statement. I've gotten as far
as being able to print the list:
% open (FILE, "/var/www/test");
% my @custom = <FILE>;
% chomp @custom;
% # print "@custom"; # this prints out 'apple orange pear'
% close FILE;
And my if statement works if I define it specifically:
% if ($server eq "apple" or $server eq "orange" or $server eq "pear")
{
display some text
% }
% } # endif $server
However, if I try to use something like:
% # if ($server eq @custom) {
display some text
% }
% } # endif $server
every $server is included in the 'display some text'. I know I'm off
a bit here, but any help or references to examples would be greatly
appreciated.
Benjamin