hijinks has asked for the wisdom of the Perl Monks concerning the following question:

I have to have output that the second column of text is always in the same spot no matter how many characters there are in the first column. I've tried this
$str = formline <<'END', $key, $value; @<<<<<<<<<<@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< END open(DEV, ">/tmp/IDS-$date") or die "can't open file!\n"; print DEV $^A; close(DEV);
but I need to run it from cron and since cron doesn't know about terminals it just creates an empty file. Is there a way to make this work?

Replies are listed 'Best First'.
Re: formated text
by Taulmarill (Deacon) on Oct 08, 2003 at 14:32 UTC
Re: formated text
by dragonchild (Archbishop) on Oct 08, 2003 at 17:01 UTC
    I second Taulmarill's suggestion of printf. It's the most common way to create fixed-width text (as opposed to tab-delimited, or what not).

    ------
    We are the carpenters and bricklayers of the Information Age.

    The idea is a little like C++ templates, except not quite so brain-meltingly complicated. -- TheDamian, Exegesis 6

    Please remember that I'm crufty and crochety. All opinions are purely mine and all code is untested, unless otherwise specified.

Re: formated text
by sgifford (Prior) on Oct 08, 2003 at 16:09 UTC
    It works fine for me when run from cron. Formatting shouldn't depend on terminals at all. What is your code doing when run from cron, and what does it do when you run it from the command-line? What do you expect it to do?
Re: formated text
by Abigail-II (Bishop) on Oct 08, 2003 at 15:02 UTC
    What exactly is your question? Do you have a question about formats, or about cron? And what do terminals have to do with your question?

    Abigail