On Feb 3, 1:57*pm, BenConrad <gu...@xxxxxx-email.com> wrote:
> Hi,
>
> I'm used to creating arrays in Perl such as:
>
> @array = (one, two, three);
> foreach $a (@array) * *{ * *print "$a\n"; }
>
> In powershell, I can't do that unless I quote each element in the
> array. *I guess that's fine if only have a few elements but If I'm
> copying and pasting a large list of elements that gets old real quick.
>
> *I've seen this trick*:
>
> function new-array {,$args}
> $array = new-array one,two,three
>
> but that seems clunky.
>
> Is there a way to create a simple array consisting of comma separated
> elements without having to quote/doublequote each one?
>
> Ben
>
> --
> BenConrad I don't want to veer too far off topic, but you should never do this
in Perl. Are you using 'use strict'? The ambiguity of what you're
really telling the interpreter can lead to weird and hard to debug
side effects. If you wanted to do that just as easily then this would
be better:
my @array = qw(one two three);