swatzz has asked for the wisdom of the Perl Monks concerning the following question:
I am not exactly new to Perl and have been writing programms quite often but i am ever so often stumped by regular expreessions in Perl. Would really appreciate if somone could give me some hints with regards to the following problem.
I have a text file to parse, only for one matchcase, which occurs multpile times in the text file. The matchcase is a long sentence (string!) but i need to extract only a part of it as output.
Here is my code:
The $line (the long sentence!) is:open FILE, "<", "XYZ.txt" or die $!; my @actionData = (); my $i = 0; while (my $line = <FILE>) { if ( $line =~ /action/ ) { push(@actionData, (split (/^\d+/, $line))); $i++; } }
I need to extract just (62,1,0,0,0,0,5,53,9,0,190) and set all non zero numbers as some key-value pair:[AHB_REPORTER][INFO]: action(62,1,0,0,0,0,5,53,9,0,190)D:/XYZ/reg/Test +s/Mcu/A_test.cCALL: (null)
and so on... Any hints would be welcome really! And thank you all in advance.a => 62 b => 1 c => 5 d => 53
PS: I have been using Perl monks for over a year now and it really has helped me with lots of doubts that needed clarification but this is also my first post here! I hope i have framed the question understandable enough and in the right format!!
|
|---|