in reply to Printing in succesive columns...

Personally, I would do it with printf. You can look up formatting options in any C book. (There are quite a few; like pack/unpack, it's like a programming language of it's own.)

$margin = 10; printf "'%${margin}s'\n", 'x'; __output__ ' x'

You don't need references to $_ in the foreach or split lines. The whole point about the default variable is that you can leave out the variable, and focus on the operation. Fewer implementation details, more result.

In related news,.... since you don't need $a or $b, just tell Perl to discard them by taking a slice of the split result:

... (split( /\t/ ))[2,3];

But you only need $c & $d for two lines, to join back together. So why not merge the two lines:

... join '/', (split( /\t/ ))[2,3];

You only use $qq to add the result of the join into @qqq, so save another line:

push @qqq, join '/', (split( /\t/ ))[2,3];

--
TTTATCGGTCGTTATATAGATGTTTGCA

Replies are listed 'Best First'.
Re: Re: Printing in succesive columns...
by Albannach (Monsignor) on Jul 07, 2003 at 21:28 UTC
    I also like printf, and your solution can also be written as:
    printf "'%*s'\n",$margin,'x';
    where the * means take the value from the next argument in the list, a feature which I've always found pretty handy.

    --
    I'd like to be able to assign to an luser