Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

Try this.

#!/usr/bin/perl -w use strict; use warnings; use Data::Dumper; my $data = join '', "U|(Memory is incorrectly balanced between the NUMA ", "nodes of this system, which will lead to poor performance. ", "See),_NUMA_CRIT_,;(/proc/vmware/NUMA/hardware),_NUMA_CRIT_", ",__REFERAL__file:__SELF__;( for details on your current ", "memory configuration),_NUMA_CRIT_,;"; print "DATA\n$data\n\n"; #(my $m_type = $data) =~ s/^((?:U|M))\|.*$/$1/; # gets U #(my $p_list = $data) =~ s/^(?:U|M)\|(.*)$/$1/; # gets U, i think thi +s is the reason you weren't getting anything # This approach does what I think you are trying for without as much w +ork for you or the computer. my ($m_type, $p_list) = split /\|/, $data, 2; my @sub_p_tmp = split /;/, $p_list; print "MTYPE: $m_type\n"; print "PLIST: $p_list\n"; my @args; # Try using # for my $p_tmp ( @sub_p_tmp ) # Instead of the c style for loop, unless you are processing HUGE arra +ys. for ( my $i = 0; $i <= $#sub_p_tmp; $i++ ) { print "$i: $sub_p_tmp[$i]\n"; # Here's your regex based method fixed to work # if ( $sub_p_tmp[$i] =~ m/^\(([^)]*)\),([^,]*),(.*)$/ ) # { # @args = ($1, $2, $3); # print "\nArgs:\n"; # print Dumper(\@args)."\n"; # } # Here's a split based approach. # in both approaches @args is overwritten each pass through the loop. my @temp = split /,/, $sub_p_tmp[$i]; if ( @temp ) { # Get rid of the extra parens. $temp[0] =~ s/^\(|\)$//g; # Overwriting the value of @args each time. # Do you mean # push @args, @temp[0..2]; # or # push @args, [ @temp[0..2]]; $temp[0] =~ s/^\(|\)$//g; @args = @temp[0..2]; print "\nArgs:\n"; print Dumper(\@args)."\n"; } }

TGI says moo

In reply to Re^2: Matching a pattern which resides within round brackets by TGI
in thread Matching a pattern which resides within round brackets by jbl_bomin

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, 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, 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.
  • Log In?

    What's my password?
    Create A New User
    and all is quiet...

    How do I use this? | Other CB clients
    Other Users?
    Others meditating upon the Monastery: (3)
    As of 2018-01-21 01:00 GMT
    Find Nodes?
      Voting Booth?
      How did you see in the new year?

      Results (227 votes). Check out past polls.