Hi
I am trying to make a perl script execute different blocks of code depending on the instruction parsed to it from an html input page
However, I am not a programmer - although I understand what is going on to some extent. Essentially the instructions are either 'Yahoo' or 'database'. I think I'm having problems setting up the conditionals correctly as well as some variables.
I am though having problems making the script execute based on the choice - at the moment it seems to only want to use 'database' (which is an internal database).
Any help would be appreciated.
$sector = "XBD"; # default sector
$threshold = 0.7; #default threshold
$duration = 6; #default duration
$periods = 0; #default duration
@dur_array = (0,0,0,0,0,0);
$datafeed = "database"; #default datafeed
# Determine which sector the user wants
@fields = split(/&/,$combo_value);
foreach $f (@fields) {
if ($f =~ m/(.*)=(.*)/) {
if ($1 eq "sector") { $sector = $2;}
if ($1 eq "threshold") { $threshold = $2;}
if ($1 eq "duration")
{
$periods++;
if ($2 eq "1") { $dur_array[0] = 1;}
elsif ($2 eq "2") { $dur_array[1] = 1;}
elsif ($2 eq "4") { $dur_array[2] = 1;}
elsif ($2 eq "12") { $dur_array[3] = 1;}
elsif ($2 eq "24") { $dur_array[4] = 1;}
elsif ($2 eq "48") { $dur_array[5] = 1;}
else { print "previous case not true";}
}
if ($1 eq "$datafeed") { $datafeed = $2;}
}
}
# now find out the components in the sector (from component text file or Yahoo DB)
if ($datafeed eq "database")
{
$comp_url = " my $v = get ($comp_url);
@components = split(",", $v);
}
elsif ($datafeed eq "Yahoo")
{
$comp_url = " my $v = get ($comp_url);
my @components = get_comps($v);
#print join(',',@components),"<BR>";
}
else { print "blah";}
print "<center><h1>Correlations between components of $sector</h1></center>\n";
$siz = $#components+1;
Jonmy
I am trying to make a perl script execute different blocks of code depending on the instruction parsed to it from an html input page
However, I am not a programmer - although I understand what is going on to some extent. Essentially the instructions are either 'Yahoo' or 'database'. I think I'm having problems setting up the conditionals correctly as well as some variables.
I am though having problems making the script execute based on the choice - at the moment it seems to only want to use 'database' (which is an internal database).
Any help would be appreciated.
$sector = "XBD"; # default sector
$threshold = 0.7; #default threshold
$duration = 6; #default duration
$periods = 0; #default duration
@dur_array = (0,0,0,0,0,0);
$datafeed = "database"; #default datafeed
# Determine which sector the user wants
@fields = split(/&/,$combo_value);
foreach $f (@fields) {
if ($f =~ m/(.*)=(.*)/) {
if ($1 eq "sector") { $sector = $2;}
if ($1 eq "threshold") { $threshold = $2;}
if ($1 eq "duration")
{
$periods++;
if ($2 eq "1") { $dur_array[0] = 1;}
elsif ($2 eq "2") { $dur_array[1] = 1;}
elsif ($2 eq "4") { $dur_array[2] = 1;}
elsif ($2 eq "12") { $dur_array[3] = 1;}
elsif ($2 eq "24") { $dur_array[4] = 1;}
elsif ($2 eq "48") { $dur_array[5] = 1;}
else { print "previous case not true";}
}
if ($1 eq "$datafeed") { $datafeed = $2;}
}
}
# now find out the components in the sector (from component text file or Yahoo DB)
if ($datafeed eq "database")
{
$comp_url = " my $v = get ($comp_url);
@components = split(",", $v);
}
elsif ($datafeed eq "Yahoo")
{
$comp_url = " my $v = get ($comp_url);
my @components = get_comps($v);
#print join(',',@components),"<BR>";
}
else { print "blah";}
print "<center><h1>Correlations between components of $sector</h1></center>\n";
$siz = $#components+1;
Jonmy