Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > tabs between fields

Reply
Thread Tools

tabs between fields

 
 
beartiger@gmail.com
Guest
Posts: n/a
 
      10-07-2005
How do I insert a tab between fields in a format?

use strict;
use warnings;

my $foo=123;
my $bar=456;

format TABLE=
@### @###
$foo, $bar;
 
Reply With Quote
 
 
 
 
usenet@DavidFilmer.com
Guest
Posts: n/a
 
      10-07-2005

(E-Mail Removed) wrote:
> I would like a tab between the values of $foo and $bar in the output.


Then why are you using the format? Why not just "$foo\t$bar"

 
Reply With Quote
 
 
 
 
beartiger@gmail.com
Guest
Posts: n/a
 
      10-07-2005

(E-Mail Removed) wrote:
> (E-Mail Removed) wrote:
> > I would like a tab between the values of $foo and $bar in the output.

>
> Then why are you using the format? Why not just "$foo\t$bar"


Because I'm a fricking idiot. It's one format in a long list of
formats and I never thought I could just get rid of the format.

Thanks.


J

 
Reply With Quote
 
usenet@DavidFilmer.com
Guest
Posts: n/a
 
      10-08-2005
http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:
> Because I'm a fricking idiot. It's one format in a long list of
> formats and I never thought I could just get rid of the format.


Maybe you wanted to preserve the space padding characteristics of the
format statement. You could do that instead with sprintf:
print sprintf "%3s\t%3s\n", $foo, $bar;

I've never liked formats. They seem very old-fashioned to me.

 
Reply With Quote
 
beartiger@gmail.com
Guest
Posts: n/a
 
      10-08-2005
(E-Mail Removed) wrote:
> (E-Mail Removed) wrote:
> > Because I'm a fricking idiot. It's one format in a long list of
> > formats and I never thought I could just get rid of the format.

>
> Maybe you wanted to preserve the space padding characteristics of the
> format statement. You could do that instead with sprintf:
> print sprintf "%3s\t%3s\n", $foo, $bar;
>
> I've never liked formats. They seem very old-fashioned to me.


Thanks. This is the first time I've tried formatting. I don't know
about old fashioned, but I find the way a format is done kind of
clunky.

I've never done sprintf either. That will come in handy.


J

 
Reply With Quote
 
michaelpgee@gmail.com
Guest
Posts: n/a
 
      10-08-2005

(E-Mail Removed) wrote:
> (E-Mail Removed) wrote:
> > Because I'm a fricking idiot. It's one format in a long list of
> > formats and I never thought I could just get rid of the format.

>
> Maybe you wanted to preserve the space padding characteristics of the
> format statement. You could do that instead with sprintf:
> print sprintf "%3s\t%3s\n", $foo, $bar;


This looks redundant, and print is repeated too.

Why not just: printf "%3s\t%3s\n", $foo, $bar;

>
> I've never liked formats. They seem very old-fashioned to me.


 
Reply With Quote
 
usenet@DavidFilmer.com
Guest
Posts: n/a
 
      10-08-2005

(E-Mail Removed) wrote:
> This looks redundant, and print is repeated too.


True, but since the OP (properly) posted trivial code, I wasn't sure if
he actually intended to assign or print in his "real" application. So I
covered both bases (at the expense of redundancy).

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Tabs -vs- Spaces: Tabs should have won. rantingrick Python 95 07-18-2011 11:07 PM
epydoc: How to add new fields as the building fields? Cyril.Liu Python 0 12-02-2008 05:01 AM
print struct fields and its member structs' fields recursively, generically call_me_anything C++ 4 09-30-2007 10:12 PM
CSV::Writer... Using tabs instead of commas (or creating excel file using tabs to seperate data) John Kopanas Ruby 2 01-29-2007 06:26 PM
List text files showing LFs and expanded tabs (was: Colorize expanded tabs) qwweeeit Python 2 12-14-2005 10:07 AM



Advertisments