in reply to Printing Variable Variables
I know this is really dumb and basic but I can't figure it out.What it is is really unnecessary. This is what arrays are for. Would you care to explain why you don't want to use an array?
update: If the reason for not using an array is that the numeric index can be really large (meaning it can be a very sparse "array"), then this is what hashes are for -- just use the numeric as the hash key instead of as an array index.#!/usr/bin/perl -w use strict; my @string = qw/Jessy Bob Nancy/; my $num = 0; while ( $num < @string ) { print "$string[$num] "; $num++; } ### or, instead of a loop, just: print "\n@string\n";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Printing Variable Variables
by awohld (Hermit) on Sep 13, 2005 at 07:47 UTC | |
by srdst13 (Pilgrim) on Sep 13, 2005 at 11:07 UTC |