V
Vito Corleone
I have an 'if' inside a 'for' like this:
--- cut ---
for (my $x = 0; $x < 100; $x++) {
if ($status eq "demo") {
$link = "demo.html";
}
else {
$link = $row[$x]->{link};
}
print $link;
}
--- cut ---
How can I take the 'if' out from the loop? I want to make it looks like
this:
--- cut ---
if ($status eq "demo") {
$link = "demo.html";
}
else {
$link = ???? ## Here I don't know
## I want something like '$row[$x]->{link}'
}
for (my $x = 0; $x < 100; $x++) {
print $link; ## Should print "demo.html"
## Or the value of $row[$x]->{link}
}
How can I do this?
Regards,
Vito
--- cut ---
for (my $x = 0; $x < 100; $x++) {
if ($status eq "demo") {
$link = "demo.html";
}
else {
$link = $row[$x]->{link};
}
print $link;
}
--- cut ---
How can I take the 'if' out from the loop? I want to make it looks like
this:
--- cut ---
if ($status eq "demo") {
$link = "demo.html";
}
else {
$link = ???? ## Here I don't know
## I want something like '$row[$x]->{link}'
}
for (my $x = 0; $x < 100; $x++) {
print $link; ## Should print "demo.html"
## Or the value of $row[$x]->{link}
}
How can I do this?
Regards,
Vito