perl command to read the coordinate {x1 y1} {x2 y2}
1
0
Entering edit mode
5.5 years ago
iyliaadhwa • 0

Hi.. i have an question about perl command. I have a data that look like this which in term of {x1 y1} {x2 y2}

{1111.6788 2234.8769} {1121.6788 2244.8769}
{2344.6756 2268.9978} {2354.6756 2278.9978}

how do i want to read the data in perl command by multiple x1 with 2 and y1 with 3.

  1. read the data of x1, y1, x2 and y2 separately.
  2. X1 multiple with 2 ,y1 multilple with 3, X2 plus with 10 and Y2 also plus with 10
  3. save the answer inside the file in this format again {X1 Y1} {X2 Y2}

I will apppriciate it if u can help me :)

Thank you

perl coordinate data • 912 views
ADD COMMENT
1
Entering edit mode
5.5 years ago

the following perl snippet should work :

#! /usr/bin/env perl
use strict;
use warnings;
while (<STDIN>){
        $_ =~ s/[{}]//g;
        my @line = split (' ', $_);
        $line[0] = $line[0] *2;
        $line[1] = $line[1] *3;
        $line[2] += 10;
        $line[3] += 10;

        print "{$line[0]        $line[1]}       {$line[2]       $line[3]}\n";
}

it reads from STDIN and prints out the values tab-delineated for now (not sure what you want/have):

{2223.3576      6704.6307}      {1131.6788      2254.8769}
{4689.3512      6806.9934}      {2364.6756      2288.9978}
ADD COMMENT

Login before adding your answer.

Traffic: 1522 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6