http://qs321.pair.com?node_id=696403


in reply to Re: Splicing Arrays on pre-defined indices
in thread Splicing Arrays on pre-defined indices


Just an update on the question i asked earlier

actually iam stuck with the below in my project , so iam putting the following piece of code from my main script
while (<process file delimited by ~ symbol>){ @data = split(/\~/,$_); # will have around 30 elems # $data[23] will have user preference column selection # user enters 3,3-7,4,9-13 etc anything he desires $data[23] =~ s/-/\.\./; # convert - to .. perl syntax # 23rd elements contains the range entered by user # for ex: 2,3-8,11-20 # i need to extract only above range ignoring rest push(@range,eval $array[23]); # i expanded here @range = map { --$_ } @range; # decrementing since array starts + from 0 # @range = grep { !$seen{$_}++ } @range; # remove duplicates in + case user enters like 2,1-10 etc # @range = sort { $a <=> $b } @range; # Sort thee indices in as +cending order like 1,2,3,4,5,6 and so on my @finalarray = @data[@range];

iam having trouble when i print final array i get all junk values, iam sure something is wrong or there can be another good approach to achieve above

you help is highly appreciated and helpful for me

sorry for not providing sample data, because file is pretty large and question is straight forward, i have spent quite sometime on above today