[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: perl panic



> Just a shot in the dark, but... maybe it will work if you
> say "%7.4f".  The number before the dot is the *total* width
> of the field, not the number of digits to the left of the
> decimal point.


Here's a little program I wrote that may help keep things straight.  I
originally posted it at

http://www.perlmonks.org/index.pl?node_id=90629


my @formats = qw(
        %s
        %10s
        %-10s
        %10.10s
        %-10.10s

        %d
        %10d
        %-10d
        %10.10d
        %-10.10d

        %f
        %10f
        %-10f
        %10.10f
        %-10.10f
        );
my %values = ( s => "JLHooker", f => "12345.67", d => "1234567" );


for my $format ( @formats ) {
        my $type = substr( $format, -1 );
        $format = "|$format|";

        printf( "%-10.10s     %s\n", $format, sprintf( $format,
$values{$type} ) );
} # for

xoxo,
Andy


--
%_=split/;/,".;;n;u;e;ot;t;her;c; ".   #   Andy Lester
'Perl ;@; a;a;j;m;er;y;t;p;n;d;s;o;'.  #   http://petdance.com
"hack";print map delete$_{$_},split//,q<   andy@petdance.com   >