Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW

Re: print to memory?

by athomason (Curate)
on Sep 10, 2000 at 00:06 UTC ( #31768=note: print w/replies, xml ) Need Help??

in reply to print to memory?

...writing TNT2 opengl drivers in perl.

Whoa! That's a strange undertaking. I hope it's only an academic exercise. In any case, accessing raw memory is largely what Perl is designed to shield you from. So as far as core Perl is concerned, you can't do that (and shouldn't be able to). A quick search didn't turn up an existing module to do this, but you could write a small XS extension (a Perl module written in C) which had routines to read to and write from specific memory locations, and then just call those in your program. Keep in mind this would most likely be insanely slow. But perhaps you could accelerate Commander Keen :-).

As far as the printing goes, you might not be far off. Provided your /dev/lp0 is configured to correctly handle raw text dumped to it, you should be able to use what you have if you make the handle writable (open(PRINTER,'>>/dev/lp0')) before printing to it. You may need to figure out how to send a page-feed, though, or just press the button yourself on the printer.

Replies are listed 'Best First'.
RE: Re: print to memory?
by spudzeppelin (Pilgrim) on Sep 10, 2000 at 19:11 UTC

    Generally, \x0c (that's ctrl-L or ^L) is a page-feed to most printers.

    I've written ofs in perl for the lpd before, it's not a difficult task :) However, I'd strongly recommend using the lpd (or at least, one of the new non-spooling print programs, such as pdq) rather than trying to write raw text to the hardware device.

    Spud Zeppelin *

      In Perl (and usually "C") string handling you can use "\f" for the formfeeds. As long as you are playing with teletype commands, you should remember that one.

      • \t ab
      • \n ewline
      • \r eturn
      • \f ormfeed
      • \b ackspace
      • \a larm
      • \e scape (also handy but a perl only idiom AFAIK)

      $you = new YOU;
      honk() if $you->love(perl)

RE: Re: print to memory?
by Rydor (Scribe) on Sep 10, 2000 at 02:00 UTC
    i was hoping something like the printer thing would work, and i think i couldn't spend my time more productively than accelerating commander keen. That game rocks!! seriously, it was the game that got me interested in computer games. I owe it my life (or perhaps it owes me my life back... i'll have to think about that) I wonder if there is commander keen for linux.......


Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://31768]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (5)
As of 2016-10-22 01:08 GMT
Find Nodes?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?

    Results (291 votes). Check out past polls.