Advertisement

05.28.2008 at 10:05AM PDT, ID: 23438797
[x]
Attachment Details

loop through string array

Asked by Dan-LL in CGI Scripting, Perl Programming Language

Tags: perl

Can someone tell me if this can be done and how as I have almost got it right, erm no I have not...

ozo gave me this one liner that works a treat
$r1t = (undef, $onename, $twoname,  $threename, $fourname, $fivename)[$r1t] || $r1t;

for my $i (1 .. 4){
$r.$i.t = (undef, $onename, $twoname,  $threename, $fourname, $fivename)[$r.$i.t] || $r.$i.t;
}

it does not return the same values as writing it long hand like this, any ideas if the code can be looped.

$r1t = (undef, $onename, $twoname,  $threename, $fourname, $fivename)[$r1t] || $r1t;
$r2 = (undef, $onename, $twoname,  $threename, $fourname, $fivename)[$r2t|| $r2;
$r3 = (undef, $onename, $twoname,  $threename, $fourname, $fivename)[$r3 || $r3;
$r4 = (undef, $onename, $twoname,  $threename, $fourname, $fivename)[$r4] || $r4tStart Free Trial
[+][-]05.28.2008 at 10:17AM PDT, ID: 21662312

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: CGI Scripting, Perl Programming Language
Tags: perl
Sign Up Now!
Solution Provided By: ozo
Participating Experts: 2
Solution Grade: A
 
 
[+][-]05.28.2008 at 10:19AM PDT, ID: 21662332

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.28.2008 at 10:20AM PDT, ID: 21662343

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.28.2008 at 10:25AM PDT, ID: 21662389

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.28.2008 at 10:25AM PDT, ID: 21662394

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.28.2008 at 10:35AM PDT, ID: 21662475

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.28.2008 at 10:50AM PDT, ID: 21662583

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.28.2008 at 11:06AM PDT, ID: 21662725

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.28.2008 at 11:16AM PDT, ID: 21662815

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628