List Info

Thread: Re: random subscripts




Re: random subscripts
country flaguser name
United States
2008-03-20 11:07:12


--- yaswanth krishna < yaswanth.krishna%40gmail.com">yaswanth.krishnagmail.com>
wrote:

&gt; Move that initialization"$c = 0;" before the foreach
> loop. Every time index
&gt; '1' is getting initialized and finally that array is
> having only one element
> whch is initialized at last
>
> -Yaswanth
>
> On Thu, Mar 20, 2008 at 10:26 AM, Donald Korrecta
> < draktrax%40yahoo.com">draktraxyahoo.com>
>; wrote:
&gt;
> >
>; > --- merlyn%40stonehenge.com">merlynstonehenge.com
&gt; <merlyn%40stonehenge.com> wrote:
&gt; >
>; > > >>&gt;>> "Donald" == Donald Korrecta
> > > < draktrax%40yahoo.com">draktraxyahoo.com <draktrax%40yahoo.com>>;
> writes:
> > >
>; > > Donald> I can get ten cards but, they are all
> the
> > > same card.
&gt; > >
>; > > Your code wouldn't get the same card each time.
&gt; > > Maybe you mean
>; > > "sometimes I get the same card".
> > >
>; > > Unless somehow you have only one card in deck.
&gt; > >
>; > > So perhaps you could post the code that has the
> > > behavior above,
&gt; > > or confirm the other two things I just said.
&gt; Also
>; > > show
>; > > how you initialize deck.
&gt; > >
>; > > --
> > > Randal L. Schwartz - Stonehenge Consulting
> Services,
> > > Inc. - +1 503 777 0095
>; > > < merlyn%40stonehenge.com">merlynstonehenge.com
&gt; <merlyn%40stonehenge.com>>
> > > <URL:http://www.stonehenge.com/merlyn/>
&gt; > > Perl/Unix/security consulting, Technical
> writing,
> > > Comedy, etc. etc.
>; > > See PerlTraining.Stonehenge.com for onsite and
> > > open-enrollment Perl training!
> > >
>; > The entire prog:
&gt; > foreach $b ("spades", "hearts", "clubs",
> "diamonds") {
> > foreach $a ("ace", 2..10, "jack", "queen", "king")
&gt; {
> > $c=0;
&gt; > $deck[&;c]= "$a of $b";
> > $c++;
> > }
> > }
> > foreach $i (1..10) }
> > $card=$deck[rand deck];
&gt; > print "Card $i is the $card;
&gt; > }
> >
>; > if i print out the result of the nested loops
&gt; > i get a list of all cards. the prog returns only
>; the
> > king of diamonds. what am i missing?
> >
>; >
>;
_____________________________________________________
&gt; > Never miss a thing. Make Yahoo your home page.
&gt; > http://www.yahoo.com/r/hs
&gt; >
> >
>;
>
> [Non-text portions of this message have been
>; removed]
>
> Thank you. Thank you. Thank you for the valuable
lesson in "WATCH WHAT YOUR DOING!!!&quot;
Such an elementary mistake!
I knew I'd kick myself as soon as I saw
the solution. Again THANK YOU!!!

__________________________________________________________
Be a better friend, newshound, and
know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ

__._,_.___
.

__,_._,___
[1]

about | contact  Other archives ( Real Estate discussion Medical topics )