undef $/; my $string = ; $string =~ s/\n//g; # strip the line returns in the middle $string =~ s/\Q][\E/],[/g; # fix the missing commas my $ref = eval $string; use Data::Dumper; print Dumper $ref; __DATA__ [[6233436.1909606,2194112.25395507],[6233761.94604823,2194103.2760573][6233761.9 4604823,2194103.2760573],[6233762.83704991,2194253.27401428][6233762.83704991,21 94253.27401428],[6233862.31905238,2194250.97103715][6233862.31905238,2194250.971 03715],[6233862.11796135,2194125.32895491][6233862.11796135,2194125.32895491],[6 233853.10995097,2194050.84399622][6233853.10995097,2194050.84399622],[6233913.26 002859,2194048.73994099][6233913.26002859,2194048.73994099],[6233915.60294322,21 93851.74997113][6233915.60294322,2193851.74997113],[6233893.64995314,2193869.222 05086][6233893.64995314,2193869.22205086],[6233850.98701156,2193903.17798063][62 33850.98701156,2193903.17798063],[6233844.27100507,2193908.52296993][6233844.271 00507,2193908.52296993],[6233815.7489989,2193931.22405435][6233815.7489989,21939 31.22405435],[6233789.86006027,2193951.83103602][6233789.86006027,2193951.831036 02],[6233674.96001573,2193955.16103198][6233674.96001573,2193955.16103198],[6233 546.54502092,2193958.87802609][6233546.54502092,2193958.87802609],[6233525.83404 865,2193959.47900245][6233525.83404865,2193959.47900245],[6233482.07901437,21939 60.74602904][6233482.07901437,2193960.74602904],[6233429.35195173,2193962.273989 1][6233429.35195173,2193962.2739891],[6233404.12906333,2193963.00396484][6233404 .12906333,2193963.00396484],[6233378.90298503,2193963.73700288][6233378.90298503 ,2193963.73700288],[6233328.37299498,2193965.19797513][6233328.37299498,2193965. 19797513],[6233360.91503536,2194114.33006681][6233360.91503536,2194114.33006681] ,[6233361.95698291,2194213.73602217][6233361.95698291,2194213.73602217],[6233362 .47195967,2194262.98903315][6233362.47195967,2194262.98903315],[6233437.67196539 ,2194261.58598941][6233437.67196539,2194261.58598941],[6233436.1909606,2194112.2 5395507]]