Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

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]
SuicideJunkie replaces stale cookies with fresh on the platter on the sideboard.
[SuicideJunkie]: So, possibly interesting thing; I had that script which was using more than all the ram to open an absurdly large spreadsheet. I set it up to spin overnight nightly, so it stopped releasing memory since it was never fully exited.
[SuicideJunkie]: Didn't expect that to be a problem. There's plenty of disk space for swap, and the memory space would be reused the next day. But apparently virtualbox dies with a guru meditation when there's no physical memory unused on start.

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (3)
As of 2017-04-26 22:44 GMT
Find Nodes?
    Voting Booth?
    I'm a fool:

    Results (491 votes). Check out past polls.