Question: perl command to read the coordinate {x1 y1} {x2 y2}
0
gravatar for iyliaadhwa
8 months ago by
iyliaadhwa0
iyliaadhwa0 wrote:

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

coordinate data perl • 256 views
ADD COMMENTlink modified 8 months ago by lieven.sterck5.5k • written 8 months ago by iyliaadhwa0
1
gravatar for lieven.sterck
8 months ago by
lieven.sterck5.5k
VIB, Ghent, Belgium
lieven.sterck5.5k wrote:

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 COMMENTlink modified 8 months ago • written 8 months ago by lieven.sterck5.5k
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1605 users visited in the last hour