Regex help

K

king

I have a script as below.

"
#!/c/perl/bin
system("typeperf \"\\Processor\(\*\)\\% C1 Time\" -sc 1 > C1.txt");
system("typeperf \"\\Processor\(\*\)\\% C2 Time\" -sc 1 > C2.txt");
system("typeperf \"\\Processor\(\*\)\\% C3 Time\" -sc 1 > C3.txt");
sleep 1;
#open(C1,"C1.txt");
#$C1_ARR=<C1>;
#close(C1);
open C1, "<C1.txt";
$C1_CONTENT = do { local $/; <C1> };
print "$C1_CONTENT\n";"

Now in the $C1_CONTENT the content is as below.
""(PDH-CSV 4.0)","\\Test_PC\Processor(0)\% C1 Time","\\HACHARYX-MOBL
\Processor(1)\% C1 Time","\\HACHARYX-MOBL\Processor(_Total)\% C1 Time"
"09/03/2010 09:58:36.052","9.797092","11.412473","10.604782"
Exiting, please wait...
The command completed successfully."

I am trying to find a regex so that I can extract the exact three
values from the scalar and put in different variables and do some
operation. I want to keep finding values repeatably and values varies
but will be in same format. In this case the values are:
"9.797092","11.412473","10.604782"

Can anybody help in this.
 
J

Jürgen Exner

king said:
Now in the $C1_CONTENT the content is as below.
""(PDH-CSV 4.0)","\\Test_PC\Processor(0)\% C1 Time","\\HACHARYX-MOBL
\Processor(1)\% C1 Time","\\HACHARYX-MOBL\Processor(_Total)\% C1 Time"
"09/03/2010 09:58:36.052","9.797092","11.412473","10.604782"

Baring any line breaks in this posting this very very much looks like a
CSV file.
Exiting, please wait...
The command completed successfully."

I am trying to find a regex so that I can extract the exact three

If this is a CSV file format then why are you trying to do it the hard
way? Just use a parser for CSV files, grap the 6th, 7th, and 8th element
and be done with it.

jue
 
U

Uri Guttman

k> I have a script as below.
k> #!/c/perl/bin
k> system("typeperf \"\\Processor\(\*\)\\% C1 Time\" -sc 1 > C1.txt");
k> system("typeperf \"\\Processor\(\*\)\\% C2 Time\" -sc 1 > C2.txt");
k> system("typeperf \"\\Processor\(\*\)\\% C3 Time\" -sc 1 > C3.txt");

learn how to use alternate delimiters. hell, that could just be done
with single quotes as i see no interpolation. the backwhacks makes it
impossible to read.

uri
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,059
Latest member
cryptoseoagencies

Latest Threads

Top