Ataualpa Albert Carmo Braga wrote:
> 
> Hi,

Hello,

>         this is my first message to list, than sorry for so basic question e
> for so bad english. I will try improve both.
> 
> I did a small script with perl and I'd like to format the output:
> 
>  C      -3.797516        2.078833        -0.795507
>  C      4.046324        0.905644        -0.106181
>  C      4.037286        0.887412        1.283492
>  C      -3.763395        2.049306        1.974280
>  C      3.510738        3.243859        1.300844
>  C      3.532632        3.241100        -0.087005
>  S      4.426205        -0.568871       -1.005668
>  O      -4.671286        -0.193843       -2.360360
>  C      3.247672        4.512625        2.076377
> [...]
> 
> like this:
> 
>  C     -3.797516        2.078833       -0.795507
>  C      4.046324        0.905644       -0.106181
>  C      4.037286        0.887412        1.283492
>  C     -3.763395        2.049306        1.974280
>  C      3.510738        3.243859        1.300844
>  C      3.532632        3.241100       -0.087005
>  S      4.426205       -0.568871       -1.005668
>  O     -4.671286       -0.193843       -2.360360
>  C      3.247672        4.512625        2.076377
> 
> Is it possible?

This will work:

# have to declare @fields here so format can see it.
my @fields;

format STDOUT =
@<<<<  @#.######      @#.######      @#.######
@fields
.

while ( <DATA> ) {
    # get the fields from the data
    @fields = split;
    write;
    }

__DATA__
 C      -3.797516        2.078833        -0.795507
 C      4.046324        0.905644        -0.106181
 C      4.037286        0.887412        1.283492
 C      -3.763395        2.049306        1.974280
 C      3.510738        3.243859        1.300844
 C      3.532632        3.241100        -0.087005
 S      4.426205        -0.568871       -1.005668
 O      -4.671286        -0.193843       -2.360360
 C      3.247672        4.512625        2.076377


perldoc perlform


John
-- 
use Perl;
program
fulfillment

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to