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
-
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.