On Mar 24, 12:09 pm, [EMAIL PROTECTED] (Bobby) wrote:
> Hi all,
>
> I'm trying to write a simple do until loop to print out the value of $strA0 
> through $striA3. What i'm doing is replacing the value of 0 through  3 in the 
> $strA by joining two strings (my $strB = "strA" . $count;). Right now my 
> script is printing $strB as below. How do i get perl to print the value of 
> $strA0 through $strA3 inside of my do until loop?  i.e.:
>
> Desired Outcome:
> VarB: A0
> VarB: A1,b,c
> VarB: A 2
> VarB: A3,d,e
>
> Current Outcome:
> VarB:strA0
> VarB:strA1
> VarB:strA2
> VarB:strA3
>
> #!/usr/bin/perl
> use strict;
> use warnings;
>
> my $strA0="A0";
> my $strA1="A1,b,c";
> my $strA2="A2";
> my $strA3="A3,d,e";
>
> my $count = 0;
>   until ($count == 4){
>      my $strB = "strA" . $count;
>     print "VarB:$strB\n";
>   $count++;
>
> }#end until loop
>
> Thanks,
>
> Mike
>
> ---------------------------------
> Never miss a thing.   Make Yahoo your homepage.

Mike,
I'm not sure why you are attempting to solve your problem without an
array as suggested by Wolf:

use strict;
use warnings;

my @strA = ('A0', 'A1,b,c', 'A2', 'A3,d,e');

foreach my $strB ( @strA )
{
    print "$strB\n";
}


# Or if you must use a counter

my $count = 0;

while ( defined($strA[$count]) )
{
   print "$strA[$count++]\n";
}

HTH, Ken


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to