perl script for processing some txt data

fabiano petrone
fabiano petrone used Ask the Experts™
on
hello,
I've a txt file with some (1158 records) registry data on the form:
object(stdClass)#2 (1) { 
	["GetAnagraficheOrdineResult"]=> object(stdClass)#3 (1) { 
		["DtoAnagraficaDataWeb"]=> array(1159) { 
			[0]=> object(stdClass)#4 (81) { 
				ARRAY_MEMBERS
				}
			[1]=> object(stdClass)#5 (81) { 
				ARRAY_MEMBERS
				}
			......
			[1158]=> object(stdClass)#1162 (81) {
			ARRAY_MEMBERS
			}
		}
 
	}
}

Open in new window


Where ARRAY_MEMBERS has the structure:
["Field_description"]=> field_type "field_value"

Open in new window

i.e.
["ProfNome"]=> string(9) "John"
["ProfCognome"]=> string(5) "Doe"
["ProfLegalMail"]=> string(32) "john.doe@mail.com"

Open in new window

...etc...

I'd like to have a perl script that -once launched from the console- loops over all the 1158 records and construct 1158 lines contained ONLY the field_value of some selected field_descriptions "comma separated", i.e.
('Doe', 'John');

Open in new window


Thanks,
Fabiano
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Dave CrossPerl programmer, author and trainer

Commented:
What have you tried? What problems are you having? Please show us your code.

Author

Commented:
Hi,
Forget to say that I'm a really newbie, usually I work on hardware.
I've made some siiimple thing in Perl years ago: nothing more.
Sorry no code for this single problem: can you help me anyway?
Thanks,
Fabiano
Software Engineer
Distinguished Expert 2018
Commented:
Not perl...  should do the majority of the request, it might need some tweaking.
grep string some-text-file | sed -e 's/^[ \t]*\["/(\'/' -e 's/".=> string\([-9]+\) "/\'/' -e 's/".*$/\');/' 

Open in new window

Author

Commented:
Thanks noci
I've build the stuff around your suggestion and it works OK
nociSoftware Engineer
Distinguished Expert 2018

Commented:
np.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial