Thank you very much for your help. This satisfies my requirement. Thanks suresh
On Thu, Feb 12, 2009 at 4:27 PM, Rob Dixon <rob.di...@gmx.com> wrote: > suresh kumar wrote: > > > > This is my code : > > > > $::dev2->getvalue($x,$y); > > $::dev3->getvalue($x,$y); > > $::dev4->getvalue($x,$y); > > $::dev5->getvalue($x,$y); > > $::dev6->getvalue($x,$y); > > $::dev7->getvalue($x,$y); > > $::dev8->getvalue($x,$y); > > $::dev9->getvalue($x,$y); > > $::dev10->getvalue($x,$y); > > $::dev11->getvalue($x,$y); > > . > > . > > . > > . > > . > > $::dev29->getvalue($x,$y); > > $::dev30->getvalue($x,$y); > > > > Here $::dev1 to $::dev30 are my objects, using that i am calling the > > function getvalue(); > > I want to make it like this, > > @dev = ($::dev2,$::dev3,$::dev4,$::dev5,........$::dev30) > > foreach my $devref (@dev) { > > $devref->getvalue($x,$y); > > } > > > > But this is not working. can anyone help me in this, so that using a > > common variable i want to rotate the objects. > > The double colon in your variable names is probably superfluous unless your > code > is in a package other than 'main'. $::dev1 is equivalent to $main::dev1 and > so > just $dev1 if the current package is the default one. > > It looks like you need an array of objects. Create them like this: > > my @dev; > > for (2 .. 30) { # Do they really start at 2? > $dev[$_] = Object->new; > } > > then you can just write > > foreach my $dev (@dev) { > $dev->getvalue($x,$y); > } > > If you want to explain more about what you mean by "using a common variable > i > want to rotate the objects" then I'm sure we can help further. > > HTH, > > Rob >