[TriLUG] perl programming question
Benjamin Reed
trilug@trilug.org
Thu, 21 Mar 2002 09:57:36 -0500
John F Davis [johndavi@us.ibm.com] wrote:
> for ($i=0, $i < $numOfPartitions; $i++) {
> #cylinder info is manipulated and not needed for this example
> print "$begCyl, $endCyl, $partHash("$drive$i"), $boot \n";
> }
>
> However, this bit doesn't work. $drive$i fails miserably. If it was
> bash, I would do ${drive}$i, but that doesn't work either.
It should be in curly braces, not parens, and your quoting is going to
confuse it (you're closing the quote at the beginning of the print statement
with the one inside %partHash). You'll probably have to do something like:
print "$begCyl, $endCyl, " . $partHash{"$drive$i"} . ", $boot \n";
--
Benjamin Reed a.k.a. Ranger Rick (ranger@befunk.com) http://ranger.befunk.com/
Boy is it cramped... whoooee! I tell ya, if I was dead, you most certainly
could NOT swing me around in HERE. -- Cat