in reply to printing a scalar as an array
I'm not quite clear on what you want. If you have space separated data, you can use split as per sh1tn's post. On the other hand, if you want the array names in the __DATA__ block, you can do this:
my @array1 = qw(1 2 3 4 5); my @array2 = qw(a b c d e); my @array3 = qw(6 7 8 9 0); my @array4 = qw(f g h i j); while (<DATA>) { foreach (eval($_)) { print "$_\n"; } print "\n"; } __DATA__ @array1; @array2; @array3; @array4;
Update: Removed the quotes around $_ - quite right AM, my mistake. I tried various approaches to this problem, and the quotes were left over from a previous one.
As to use strict, I always always always use strict. In future I'll leave it in when posting code snippets.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: printing a scalar as an array
by tphyahoo (Vicar) on Feb 23, 2005 at 12:26 UTC | |
by dragonchild (Archbishop) on Feb 23, 2005 at 13:05 UTC | |
by blazar (Canon) on Feb 24, 2005 at 09:40 UTC | |
by Anonymous Monk on Feb 23, 2005 at 13:56 UTC | |
by RazorbladeBidet (Friar) on Feb 23, 2005 at 14:01 UTC | |
by dragonchild (Archbishop) on Feb 23, 2005 at 14:13 UTC | |
by RazorbladeBidet (Friar) on Feb 23, 2005 at 14:23 UTC | |
by Anonymous Monk on Feb 23, 2005 at 14:23 UTC | |
by RazorbladeBidet (Friar) on Feb 23, 2005 at 14:33 UTC | |
|