Hi
my @array1; my $data = "[0|0|{A=145,B=2,C=12,D=18}|!][0|0|{A=167,B=2,C=67,D=1 +7}|.1iit][196|0|{A=244,B=6,C=67,D=12}|10:48AM][204|0|{A=9,B=201,C=61, +D=11}|Calculator][66|0|{A=145,B=450,C=49,D=14}|phone]0|0|{A=145,B=2,C +=12,D=18}|!0|0|{A=167,B=2,C=67,D=17}|.1iit196|0|{A=244,B=6,C=67,D=12} +|10:48AM204|0|{A=9,B=201,C=61,D=11}|Calculator66|0|{A=145,B=450,C=49, +D=14}|phone"; my $high = 0; my @values = split(/\[([^\]]+)\]/,$data) ; print "Values is @values \n"; foreach(@values) { #I want the value that preceeds the first occurence of | in ea +ch array element, i.e 0,0,196,204,etc.. my ($conf,$rest)= split(/\|/,$_) ; print "Conf is $conf \n"; print "Rest is $rest \n"; push(@array1, $conf ); push (@array2, $rest); print "Array 1 is @array1 \n"; print "Array 2 is @array2 \n"; } $conf = highest(@array1); my $i=0; #I want the index value of the element that contains the highest conf +value..in this case 204 for (@myarray1) { last if $conf eq $_; $i++; }; print "$conf=$i\n"; #I want to print the rest of the string that was split in the sam +e index position, $rest = @array2[$i]; print "Rest is $rest \n"; # To get the higest conf value sub highest { my @data = @_; my $high = 0; for(@data) { $high = $_ if $_ > $high; } $high; }
I tried this..but I'm not getting anywhere close to the output that I need... THanks, Perllace

In reply to Re^3: (weird dup - please reap) Parsing and Obtaining Values from output by Perllace
in thread Parsing and Obtaining Values from output by Perllace

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



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.