Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

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

In reply to Re^2: Splicing Arrays on pre-defined indices by harishnuti
in thread Splicing Arrays on pre-defined indices by harishnuti

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (6)
As of 2024-03-28 11:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found