Dear Monks,
I would like to use the ".." as a loop operator but in a string. Is there any simple perl-ish way I can accomplish this? For some reason, I thought
perl would support this, but it doesn't.
my $arr=[1,2,3,4,5,6,7];
my $loop="2,4..5";
splice @$arr,$_,0,999 foreach($loop);
I want $arr to be [1, 2, 999, 3, 999, 999, 4, 5, 6, 7]. This works fine if you pass in 2,4..5 instead of "2,4..5".
I notice that '2', '4'..'5' will also work, but when the .. operator is within string, it does not.
Thank you for your time!
Michael