Just trying to do below on array stuff
actually iam stuck with the below , 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 can enter 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 c
+ase user enters like 2,1-10 etc
@range = sort { $a <=> $b } @range; # Sort the indices in ascen
+ding 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.
i have spent quite sometime on above today
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.