in reply to Matching a pattern which resides within round brackets
I've been able to resolve the this with the following code, which seems to give me the output I'm looking for:
#!/usr/bin/perl -w use strict; use Data::Dumper; my $data = "U|(Memory is incorrectly balanced between the NUMA "; $data .= "nodes of this system, which will lead to poor performance. +"; $data .= "See),_NUMA_CRIT_,;(/proc/vmware/NUMA/hardware),_NUMA_CRIT_"; $data .= ",__REFERAL__file:__SELF__;( for details on your current "; $data .= "memory configuration),_NUMA_CRIT_,;"; (my $m_type = $data) =~ s/^((?:U|M))\|.*$/$1/; (my $p_list = $data) =~ s/^(?:U|M)\|(.*)$/$1/; my @sub_p_tmp = split(/;/,$p_list); print "sub_p_tmp:\n"; print Dumper(@sub_p_tmp); my @args; for ( my $i = 0; $i <= $#sub_p_tmp; $i++ ) { $sub_p_tmp[$i] =~ s/,$//; if ( $sub_p_tmp[$i] =~ m/^\((.*)\),(.*),(.*)$/ ) { push @args, ($1, $2, $3); } elsif ( $sub_p_tmp[$i] =~ m/^\((.*)\),(.*)$/ ) { push @args, ($1, $2); } } #print "$m_type\n\n$p_list\n\n".Dumper(@sub_p_tmp)."\n"; print "\nArgs:\n"; print Dumper(@args)."\n";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Matching a pattern which resides within round brackets
by TGI (Parson) on Nov 28, 2008 at 20:09 UTC | |
by jbl_bomin (Sexton) on Dec 04, 2008 at 15:42 UTC |