output confusion

H

Huub

Hi,

I wrote a script that reads from a database and should print to labels
on a printer. It did work, but the text is out of proportion. I first
got advise to use PCL, but I didn't get that working. Next advise was to
use PostScript::Simple. I think I have that working, although loading
the generated .ps file couldn't be loaded by Evince that kept showing
"loading".
Now I have a question: when I write to file, I do this:

open(out,">$FILE");
print out "some text\n";
print out "some text2\n";
close(out);

Now, with PS, I have to use e.g.

my $ps = new PostScript::Simple(....);
$ps->text(10,10,"some text");
$ps->text(10,11,"some text2"); (?)
$ps->output("file.ps");

I suppose I just should replace all lines

print out "some text";

by

$ps->text(<x>,<y>,"some text");

Is this correct?

Thanks for helping.

Huub
 
M

Mumia W.

Hi,

I wrote a script that reads from a database and should print to labels
on a printer. It did work, but the text is out of proportion. I first
got advise to use PCL, but I didn't get that working. Next advise was to
use PostScript::Simple. I think I have that working, although loading
the generated .ps file couldn't be loaded by Evince that kept showing
"loading".
Now I have a question: when I write to file, I do this:

open(out,">$FILE");
print out "some text\n";
print out "some text2\n";
close(out);

Now, with PS, I have to use e.g.

my $ps = new PostScript::Simple(....);
$ps->text(10,10,"some text");
$ps->text(10,11,"some text2"); (?)
$ps->output("file.ps");

I suppose I just should replace all lines

print out "some text";

by

$ps->text(<x>,<y>,"some text");

Is this correct?

Thanks for helping.

Huub

It's pretty close to that. Do the first example at the top of the POD
for PostScript::Simple. The POD tells you how to set the font and colour.

You can read the POD by doing "perldoc PostScript::Simple"
 
H

Huub

It's pretty close to that. Do the first example at the top of the POD
for PostScript::Simple. The POD tells you how to set the font and colour.

You can read the POD by doing "perldoc PostScript::Simple"

OK, thank you. I've been experimenting and got some nice results. One
odd(?) thing that catches my eye is that the text is written bottom -
up, instead of top - down. And I do start at (6, 12) with the next being
(6, 17). Any explanation?
 
T

Tad McClellan

Huub said:
I do this:

open(out,">$FILE");


Don't do that!


Do use UPPER CASE filehandles.

Do use lower case variable names.

Do check the return value from open().

Do use the 3-argument form of open().

Do include the $! variable in your diagnostic message.

Do include the delimited filename in your diagnostic message.

Putting all of that together, you should model your opens like this:

open my $out, '>', $file or die "could not open '$file' $!";
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,053
Latest member
BrodieSola

Latest Threads

Top