Trailing Spaces -- Format Perl

Discussion in 'Perl Misc' started by KVN Chary, Sep 29, 2004.

  1. KVN Chary

    KVN Chary Guest

    Hello,

    my $var1 = "temp";
    my $var2 = "123";
    my $space = " ";

    format STDOUT =
    @<<<<<<<<< @<<< @<<<<<<<<<<<<<<<<<<<<<<<<<
    $var1,$var2,$space
    ..

    I need to put 26 spaces at the end of line. But this code doesn't work?
    How can I do this using FORMAT Perl Command?

    Thanks
    KVN
     
    KVN Chary, Sep 29, 2004
    #1
    1. Advertising

  2. KVN Chary wrote:
    >
    > my $var1 = "temp";
    > my $var2 = "123";
    > my $space = " ";
    >
    > format STDOUT =
    > @<<<<<<<<< @<<< @<<<<<<<<<<<<<<<<<<<<<<<<<
    > $var1,$var2,$space
    > .
    >
    > I need to put 26 spaces at the end of line. But this code doesn't work?
    > How can I do this using FORMAT Perl Command?


    Are you sure that you need to use format? :)

    formline '@<<<<<<<<< @<<< @<<<<<<<<<<<<<<<<<<<<<<<<<', $var1, $var2, $space;

    print STDOUT pack 'A42', $^A;



    John
    --
    use Perl;
    program
    fulfillment
     
    John W. Krahn, Sep 29, 2004
    #2
    1. Advertising

  3. KVN Chary wrote:
    > Hello,
    >
    > my $var1 = "temp";
    > my $var2 = "123";
    > my $space = " ";
    >
    > format STDOUT =
    > @<<<<<<<<< @<<< @<<<<<<<<<<<<<<<<<<<<<<<<<
    > $var1,$var2,$space
    > .
    >
    > I need to put 26 spaces at the end of line. But this code doesn't work?
    > How can I do this using FORMAT Perl Command?
    >
    > Thanks
    > KVN


    You might try:
    printf "%-8s %-3s ",$var1,$var2
    print ' ' x 26 , "\n";

    --
    ___ _ ____ ___ __ __
    / _ )(_) / /_ __ / _ \___ _/ /_/ /____ ___
    / _ / / / / // / / ___/ _ `/ __/ __/ _ \/ _ \
    /____/_/_/_/\_, / /_/ \_,_/\__/\__/\___/_//_/
    /___/
    Texas Instruments ASIC Circuit Design Methodlogy Group
    Dallas, Texas, 214-480-4455,
     
    Billy N. Patton, Sep 29, 2004
    #3
  4. KVN Chary

    Joe Smith Guest

    KVN Chary wrote:

    > I need to put 26 spaces at the end of line.


    Have you considered: $space = ' ' x 26;
     
    Joe Smith, Sep 30, 2004
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Les Caudle
    Replies:
    0
    Views:
    671
    Les Caudle
    Mar 7, 2004
  2. Ben
    Replies:
    5
    Views:
    2,159
    jongalloway
    Jan 16, 2005
  3. John B. Matthews
    Replies:
    4
    Views:
    694
    John B. Matthews
    Sep 12, 2008
  4. Roedy Green
    Replies:
    3
    Views:
    656
  5. johkar
    Replies:
    2
    Views:
    3,032
    Mayeul
    Dec 10, 2009
Loading...

Share This Page